Backend Development 7 min read

How to Run and Customize Nacos from Source for Seamless Microservice Development

This guide explains how to download, build, and run Nacos from source, customize its UI, ensure server‑client version consistency, and modify configuration files, providing step‑by‑step commands and code snippets for Linux, macOS, and Windows environments.

Java Architecture Diary
Java Architecture Diary
Java Architecture Diary
How to Run and Customize Nacos from Source for Seamless Microservice Development

Official Standard Run Method

Download and extract runnable package

<code>curl -O https://github.com/alibaba/nacos/releases/download/1.3.2/nacos-server-1.3.2.tar.gz
 tar -zxvf nacos-server-1.3.tar.gz
 cd nacos/bin</code>

Execute Run

<code># Linux/Unix/macOS startup command (standalone means single‑node mode)
sh startup.sh -m standalone

# If using Ubuntu or encountering a "[[" symbol error, try:
bash startup.sh -m standalone

# Windows startup command (or double‑click startup.cmd)
cmd startup.cmd</code>

Why Run from Source?

1. Convenience during development

If you migrate from Spring Cloud Netflix to Spring Cloud Alibaba, Nacos becomes a core dependency for service discovery and configuration management. Starting the microservice business requires checking whether the Nacos Server is up, and the traditional unzip‑install method is cumbersome. Running Nacos directly from source as part of the framework simplifies this process.

2. UI customization

With the unzip‑run method, modifying the UI is nearly impossible; you would need to download the source, adjust the UI, and rebuild.

<code>git clone https://github.com/alibaba/nacos.git

cd nacos/

mvn -Prelease-nacos -Dmaven.test.skip=true clean install -U
ls -al distribution/target/
# change the $version to your actual path
cd distribution/target/nacos-server-$version/nacos/bin</code>

Running from source allows you to tweak the UI and rebuild to see the effect immediately.

3. Keep Server & Client versions consistent

Microservice projects evolve quickly; each Nacos Client version may require a matching Server version, leading to high upgrade costs for users.

Nacos maintains good backward compatibility for minor versions, but major versions (e.g., 1.2 → 1.3) can introduce significant changes such as permission updates. Keeping versions aligned is recommended.

Running from source makes it easy to ensure version consistency.

Implementation Steps

1. Download Nacos source code

Only retain the

nacos-console

module; other modules can be removed.

Nacos source structure
Nacos source structure

2. Nacos source structure overview

<code>├── pom.xml
└── src
    ├── main
    │   ├── java
    │   │   └── com
    │   │       └── alibaba
    │   │           └── nacos
    │   │               ├── Nacos.java   # main entry class
    │   │               └── console      # console related source
    │   └── resources
    │       ├── application.properties  # Nacos config file
    │       └── static                  # static page directory
    └── test                           # unit tests</code>

3. Modify Nacos.java class

Add two parameters in the

main

method: whether to run in standalone mode and whether to disable permission checks.

<code>@SpringBootApplication(scanBasePackages = "com.alibaba.nacos")
@ServletComponentScan
@EnableScheduling
public class Nacos {
    public static void main(String[] args) {
        // set standalone mode via environment variable
        System.setProperty(ConfigConstants.STANDALONE_MODE, "true");
        // disable authentication via environment variable
        System.setProperty(ConfigConstants.AUTH_ENABLED, "false");
        SpringApplication.run(Nacos.class, args);
    }
}</code>

4. Update console/pom.xml

Since the Nacos BOM is not used, add explicit version numbers to all dependencies.

Some packages (nacos-config, nacos-naming) are not available in the central repository; change their

groupId

to

com.pig4cloud.nacos

to download them.

<code>&lt;dependency&gt;
  &lt;groupId&gt;com.pig4cloud.nacos&lt;/groupId&gt;
  &lt;artifactId&gt;nacos-config&lt;/artifactId&gt;
  &lt;version&gt;1.3.2&lt;/version&gt;
&lt;/dependency&gt;
&lt;dependency&gt;
  &lt;groupId&gt;org.apache.tomcat.embed&lt;/groupId&gt;
  &lt;artifactId&gt;tomcat-embed-jasper&lt;/artifactId&gt;
  &lt;version&gt;7.0.59&lt;/version&gt;
&lt;/dependency&gt;
&lt;dependency&gt;
  &lt;groupId&gt;com.pig4cloud.nacos&lt;/groupId&gt;
  &lt;artifactId&gt;nacos-naming&lt;/artifactId&gt;
  &lt;version&gt;1.3.2&lt;/version&gt;
&lt;/dependency&gt;
...</code>

Summary

After applying the above modifications, the source reference is: https://gitee.com/log4j/pig [1].

Whether to run Nacos from source depends on your specific scenario; choose the approach that best fits your project.

References

[1] https://gitee.com/log4j/pig: https://gitee.com/log4j/pig/blob/master/pig-register/pom.xml

Javamicroservicesservice discoveryNacosSpring Cloudcustom UIsource build
Java Architecture Diary
Written by

Java Architecture Diary

Committed to sharing original, high‑quality technical articles; no fluff or promotional content.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.