alibaba / nacos

an easy-to-use dynamic service discovery, configuration and service management platform for building cloud native applications.
https://nacos.io
Apache License 2.0
30.29k stars 12.84k forks source link

[spring boot+nacos] application.properties don't work #1727

Closed horsen689 closed 5 years ago

horsen689 commented 5 years ago

1.application.properties:(this don't work)

nacos.config.server-addr=127.0.0.1:8848
nacos.config.enabled=true
nacos.config.data-id=example
nacos.config.group=DEFAULT_GROUP
nacos.config.type=properties
nacos.config.auto-refresh=true

2.spring boot application class:(this's right)

@NacosPropertySource(dataId = "example",autoRefreshed = true)
@SpringBootApplication
public class DubboApplication {
...

why?

horsen689 commented 5 years ago

pom:

                <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter</artifactId>
            <version>2.1.7.RELEASE</version>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <version>2.1.7.RELEASE</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.apache.dubbo</groupId>
            <artifactId>dubbo-spring-boot-starter</artifactId>
            <version>2.7.3</version>
        </dependency>

        <dependency>
            <groupId>org.apache.dubbo</groupId>
            <artifactId>dubbo-registry-nacos</artifactId>
            <version>2.7.3</version>
        </dependency>

        <dependency>
            <groupId>com.alibaba.boot</groupId>
            <artifactId>nacos-config-spring-boot-starter</artifactId>
            <version>0.2.3</version>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
            <version>2.1.7.RELEASE</version>
        </dependency>      
chuntaojun commented 5 years ago

Please see the wiki introduce related document,The properties of the configuration only limited to preload mode

wiki