Nacos Configuration Center Project
Generate a basic web project with the Nacos Configuration Center example.
What’s included
The template introduces lodsve-boot-starter-nacos in the basic project, and demonstrates the connection address, namespace, group and extended configuration file of Nacos Config in bootstrap.yml.
Generate project
Press first Version preparation steps for Quickstart Setting LODSVE_BOOT_VERSION:
# Template release version; when installing from source code, it is changed to the locally installed version.
ARCHETYPE_VERSION=1.0.3
# Set the selected Lodsve Boot version before continuing.
: "${LODSVE_BOOT_VERSION:?Set LODSVE_BOOT_VERSION first}"
mvn archetype:generate \
-DinteractiveMode=false \
-DarchetypeGroupId=com.lodsve.archetype \
-DarchetypeArtifactId=lodsve-archetype-nacos \
-DarchetypeVersion="$ARCHETYPE_VERSION" \
-DgroupId=com.example \
-DartifactId=demo-nacos \
-Dversion=1.0.0-SNAPSHOT \
-Dpackage=com.example.demo \
-Dauthor=developer \
-DbootVersion="$LODSVE_BOOT_VERSION" \
-Dport=8080 \
-DcontextPath=/demo
Connect with Nacos
Modify src/main/resources/bootstrap.yml after generation:
- Set
spring.cloud.nacos.config.server-addras the actual service address. - Replace
namespaceandgroupwith existing configuration spaces and groups in the environment. - The template is set to
file-extension: ymland the corresponding configuration file is prepared according to the application name; the example also readsapplication.ymlof the same group throughextension-configs. - Check the account, network, and configuration read permissions; the template turns off automatic configuration refresh by default.
The default address of the template is http://localhost:8848, namespace and group are just example values. It does not create Nacos services or publish remote configurations for you.
Version adaptation
The current template uses the bootstrap.yml method. Whether to enable Bootstrap configuration loading depends on the Spring Cloud / Nacos dependency version used. You cannot just modify bootVersion and assume that the configuration loading mechanism will also automatically complete the migration.
Press first Quickstart Check the project build, and then confirm the actual connection address, namespace, group and Data ID from the startup log.
