|
|
@@ -0,0 +1,35 @@ |
|
|
|
package test; |
|
|
|
|
|
|
|
|
|
|
|
import com.alibaba.nacos.api.config.annotation.NacosValue; |
|
|
|
import com.alibaba.nacos.spring.context.annotation.config.NacosPropertySource; |
|
|
|
import org.springframework.boot.SpringApplication; |
|
|
|
import org.springframework.boot.autoconfigure.SpringBootApplication; |
|
|
|
import org.springframework.context.ConfigurableApplicationContext; |
|
|
|
import org.springframework.web.bind.annotation.GetMapping; |
|
|
|
import org.springframework.web.bind.annotation.RestController; |
|
|
|
|
|
|
|
@SpringBootApplication |
|
|
|
@NacosPropertySource(dataId = "springboot2-nacos-config", autoRefreshed = true) |
|
|
|
@RestController |
|
|
|
public class Test{ |
|
|
|
|
|
|
|
public static void main(String[] args) { |
|
|
|
try { |
|
|
|
ConfigurableApplicationContext context = SpringApplication.run(Test.class, args); |
|
|
|
System.out.print(context.getEnvironment().getProperty("nacos.test.propertie")); |
|
|
|
|
|
|
|
}catch(Exception e) { |
|
|
|
e.printStackTrace(); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
@NacosValue(value = "${nacos.test.propertie:123}", autoRefreshed = true) |
|
|
|
private String testProperties; |
|
|
|
|
|
|
|
@GetMapping("/test") |
|
|
|
public String test(){ |
|
|
|
return testProperties; |
|
|
|
} |
|
|
|
} |