以下是启动之后控制台信息,程序正常启动了但是,并没有像网上的那些图一样读取到Loading nacos data里面的配置文件信息,
也没有加载Located property source这一项
请问是我自己配置出了问题吗?
配置文件以及nacos控制台在最下面,希望可以耐心看下去!!
2021-01-08 15:16:27.886 INFO 19156 --- [ main] c.c.p.c.PsychomallCouponApplication : Starting PsychomallCouponApplication using Java 1.8.0_212 on DESKTOP-4R48HFU with PID 19156 (C:\psychomall\psychomall-coupon\target\classes started by cjl in C:\psychomall)
2021-01-08 15:16:27.891 INFO 19156 --- [ main] c.c.p.c.PsychomallCouponApplication : No active profile set, falling back to default profiles: default
2021-01-08 15:16:29.099 INFO 19156 --- [ main] o.s.cloud.context.scope.GenericScope : BeanFactory id=d8ff724f-f8ee-31d0-8d71-3828b95fdf65
2021-01-08 15:16:29.502 INFO 19156 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 7000 (http)
2021-01-08 15:16:29.516 INFO 19156 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2021-01-08 15:16:29.516 INFO 19156 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.41]
2021-01-08 15:16:29.641 INFO 19156 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2021-01-08 15:16:29.641 INFO 19156 --- [ main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 1678 ms
Loading class `com.mysql.jdbc.Driver'. This is deprecated. The new driver class is `com.mysql.cj.jdbc.Driver'. The driver is automatically registered via the SPI and manual loading of the driver class is generally unnecessary.
_ _ |_ _ _|_. ___ _ | _
| | |\/|_)(_| | |_\ |_)||_|_\
/ |
3.4.1
2021-01-08 15:16:31.360 INFO 19156 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor'
2021-01-08 15:16:31.977 INFO 19156 --- [ main] o.s.s.c.ThreadPoolTaskScheduler : Initializing ExecutorService 'Nacos-Watch-Task-Scheduler'
2021-01-08 15:16:32.760 INFO 19156 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 7000 (http) with context path ''
2021-01-08 15:16:32.772 INFO 19156 --- [ main] c.a.c.n.registry.NacosServiceRegistry : nacos registry, DEFAULT_GROUP psychomall-coupon 192.168.56.1:7000 register finished
2021-01-08 15:16:32.832 INFO 19156 --- [nio-7000-exec-2] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring DispatcherServlet 'dispatcherServlet'
2021-01-08 15:16:32.833 INFO 19156 --- [nio-7000-exec-2] o.s.web.servlet.DispatcherServlet : Initializing Servlet 'dispatcherServlet'
2021-01-08 15:16:32.834 INFO 19156 --- [nio-7000-exec-2] o.s.web.servlet.DispatcherServlet : Completed initialization in 1 ms
2021-01-08 15:16:33.132 INFO 19156 --- [ main] c.c.p.c.PsychomallCouponApplication : Started PsychomallCouponApplication in 6.409 seconds (JVM running for 7.412)
2021-01-08 15:16:51.333 INFO 19156 --- [nio-7000-exec-3] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
2021-01-08 15:16:51.334 WARN 19156 --- [nio-7000-exec-3] com.zaxxer.hikari.util.DriverDataSource : Registered driver with driverClassName=com.mysql.jdbc.Driver was not found, trying direct instantiation.
2021-01-08 15:16:52.001 INFO 19156 --- [nio-7000-exec-3] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed.
这是我的bootstrap.properties文件:
spring.application.name=psychomall-coupon
spring.cloud.nacos.config.server-addr=127.0.0.1:8848
spring.cloud.nacos.config.namespace=a4f25a10-2ae3-4445-9a42-6b9b968d6e08
spring.cloud.nacos.config.group=prod
spring.cloud.nacos.config.extension-configs[0]=datasource.yml
spring.cloud.nacos.config.extension-configs[0].group=dev
spring.cloud.nacos.config.extension-configs[0].refresh=true
spring.cloud.nacos.config.extension-configs[1]=mybatis.yml
spring.cloud.nacos.config.extension-configs[1].group=dev
spring.cloud.nacos.config.extension-configs[1].refresh=true
spring.cloud.nacos.config.extension-configs[2]=other.yml
spring.cloud.nacos.config.extension-configs[2].group=dev
spring.cloud.nacos.config.extension-configs[2].refresh=true
我的代码如下:
@RestController
@RequestMapping("coupon/coupon")
@RefreshScope
public class CouponController {
@Autowired
private CouponService couponService;
@Value("${coupon.user.name}")
private String name;
@Value("${coupon.user.age}")
private Integer age;
@RequestMapping("/test")
public R test(){
return R.ok().put("name",name).put("age",age);
}
我项目里面的application.properties文件内容如下:
coupon.user.name=zhangsan
coupon.user.age=23
在nacos控制台修改配置文件之后刷新网页还是原来的配置信息
我的依赖如下:
<!-- 服务注册/发现-->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-ribbon</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- 配置中心来做配置管理-->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-alibaba-dependencies</artifactId>
<version>2.2.3.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
在控制台里面修改配置文件之后并不能实现动态刷新的效果。
希望有大神可以帮我解答问题,是版本冲突,还是他出现了BUG