2022-04-05 01:39:29.126 WARN 3796 --- [Thread-7] c.a.n.common.http.HttpClientBeanHolder : [HttpClientBeanHolder] Start destroying common HttpClient
2022-04-05 01:39:29.126 WARN 3796 --- [Thread-15] c.a.nacos.common.notify.NotifyCenter : [NotifyCenter] Start destroying Publisher
2022-04-05 01:39:29.128 WARN 3796 --- [Thread-15] c.a.nacos.common.notify.NotifyCenter : [NotifyCenter] Destruction of the end
2022-04-05 01:41:35.729 INFO 13348 --- [main] c.h.e.upms.ability.UpmsApplication : The following 1 profile is active: "development"
2022-04-05 01:41:37.969 INFO 13348 --- [main] .s.d.r.c.RepositoryConfigurationDelegate : Multiple Spring Data modules found, entering strict repository configuration mode!
2022-04-05 01:41:37.969 INFO 13348 --- [main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode.
2022-04-05 01:41:38.194 INFO 13348 --- [main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 212 ms. Found 12 JPA repository interfaces.
2022-04-05 01:41:38.860 INFO 13348 --- [main] .s.d.r.c.RepositoryConfigurationDelegate : Multiple Spring Data modules found, entering strict repository configuration mode!
2022-04-05 01:41:38.862 INFO 13348 --- [main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data Redis repositories in DEFAULT mode.
2022-04-05 01:41:38.875 INFO 13348 --- [main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 3 ms. Found 0 Redis repository interfaces.
2022-04-05 01:41:39.317 WARN 13348 --- [main] o.m.s.mapper.ClassPathMapperScanner : No MyBatis mapper was found in '[cn.herodotus.eurynome.upms.ability]' package. Please check your configuration.
2022-04-05 01:41:39.323 INFO 13348 --- [main] faultConfiguringBeanFactoryPostProcessor : No bean named 'errorChannel' has been explicitly defined. Therefore, a default PublishSubscribeChannel will be created.
2022-04-05 01:41:39.339 INFO 13348 --- [main] faultConfiguringBeanFactoryPostProcessor : No bean named 'integrationHeaderChannelRegistry' has been explicitly defined. Therefore, a default DefaultHeaderChannelRegistry will be created.
2022-04-05 01:41:39.409 INFO 13348 --- [main] o.s.cloud.context.scope.GenericScope : BeanFactory id=c5bcc18c-abab-32dd-80e2-8e50d4913360
2022-04-05 01:41:39.979 INFO 13348 --- [main] trationDelegate$BeanPostProcessorChecker : Bean 'cn.herodotus.eurynome.security.configuration.MethodSecurityMetadataConfiguration' of type [cn.herodotus.eurynome.security.configuration.MethodSecurityMetadataConfiguration$$EnhancerBySpringCGLIB$$ab3000d1] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2022-04-05 01:41:40.021 INFO 13348 --- [main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.cloud.stream.config.BindersHealthIndicatorAutoConfiguration' of type [org.springframework.cloud.stream.config.BindersHealthIndicatorAutoConfiguration] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2022-04-05 01:41:40.024 INFO 13348 --- [main] trationDelegate$BeanPostProcessorChecker : Bean 'bindersHealthContributor' of type [org.springframework.cloud.stream.config.BindersHealthIndicatorAutoConfiguration$BindersHealthContributor] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2022-04-05 01:41:40.028 INFO 13348 --- [main] trationDelegate$BeanPostProcessorChecker : Bean 'bindersHealthIndicatorListener' of type [org.springframework.cloud.stream.config.BindersHealthIndicatorAutoConfiguration$BindersHealthIndicatorListener] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2022-04-05 01:41:40.034 INFO 13348 --- [main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.cloud.stream.binder.kafka.config.ExtendedBindingHandlerMappingsProviderConfiguration' of type [org.springframework.cloud.stream.binder.kafka.config.ExtendedBindingHandlerMappingsProviderConfiguration$$EnhancerBySpringCGLIB$$72ecae0b] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2022-04-05 01:41:40.037 INFO 13348 --- [main] trationDelegate$BeanPostProcessorChecker : Bean 'kafkaExtendedPropertiesDefaultMappingsProvider' of type [org.springframework.cloud.stream.binder.kafka.config.ExtendedBindingHandlerMappingsProviderConfiguration$$Lambda$663/818464427] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2022-04-05 01:41:40.040 INFO 13348 --- [main] trationDelegate$BeanPostProcessorChecker : Bean 'BindingHandlerAdvise' of type [org.springframework.cloud.stream.config.BindingHandlerAdvise] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2022-04-05 01:41:40.041 INFO 13348 --- [main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.cloud.commons.config.CommonsConfigAutoConfiguration' of type [org.springframework.cloud.commons.config.CommonsConfigAutoConfiguration] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2022-04-05 01:41:40.043 INFO 13348 --- [main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.cloud.client.loadbalancer.LoadBalancerDefaultMappingsProviderAutoConfiguration' of type [org.springframework.cloud.client.loadbalancer.LoadBalancerDefaultMappingsProviderAutoConfiguration] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2022-04-05 01:41:40.044 INFO 13348 --- [main] trationDelegate$BeanPostProcessorChecker : Bean 'loadBalancerClientsDefaultsMappingsProvider' of type [org.springframework.cloud.client.loadbalancer.LoadBalancerDefaultMappingsProviderAutoConfiguration$$Lambda$664/2072709038] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2022-04-05 01:41:40.047 INFO 13348 --- [main] trationDelegate$BeanPostProcessorChecker : Bean 'defaultsBindHandlerAdvisor' of type [org.springframework.cloud.commons.config.DefaultsBindHandlerAdvisor] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2022-04-05 01:41:40.054 INFO 13348 --- [main] trationDelegate$BeanPostProcessorChecker : Bean 'spelConverter' of type [org.springframework.cloud.stream.config.SpelExpressionConverterConfiguration$SpelConverter] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2022-04-05 01:41:40.158 INFO 13348 --- [main] trationDelegate$BeanPostProcessorChecker : Bean 'spring.cloud.sentinel-com.alibaba.cloud.sentinel.SentinelProperties' of type [com.alibaba.cloud.sentinel.SentinelProperties] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2022-04-05 01:41:40.161 INFO 13348 --- [main] trationDelegate$BeanPostProcessorChecker : Bean 'com.alibaba.cloud.sentinel.custom.SentinelAutoConfiguration' of type [com.alibaba.cloud.sentinel.custom.SentinelAutoConfiguration] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2022-04-05 01:41:40.176 INFO 13348 --- [main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.integration.config.IntegrationManagementConfiguration' of type [org.springframework.integration.config.IntegrationManagementConfiguration] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2022-04-05 01:41:40.181 INFO 13348 --- [main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.boot.autoconfigure.integration.IntegrationAutoConfiguration$IntegrationJmxConfiguration' of type [org.springframework.boot.autoconfigure.integration.IntegrationAutoConfiguration$IntegrationJmxConfiguration] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2022-04-05 01:41:40.201 INFO 13348 --- [main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.boot.autoconfigure.jmx.JmxAutoConfiguration' of type [org.springframework.boot.autoconfigure.jmx.JmxAutoConfiguration] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2022-04-05 01:41:40.214 INFO 13348 --- [main] trationDelegate$BeanPostProcessorChecker : Bean 'mbeanServer' of type [com.sun.jmx.mbeanserver.JmxMBeanServer] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2022-04-05 01:41:40.251 INFO 13348 --- [main] trationDelegate$BeanPostProcessorChecker : Bean 'integrationChannelResolver' of type [org.springframework.integration.support.channel.BeanFactoryChannelResolver] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2022-04-05 01:41:40.366 DEBUG 13348 --- [main] e.w.c.UndertowWebServerFactoryCustomizer : [Herodotus] |- Plugin [Herodotus Undertow WebServer Factory Customizer] Auto Configure.
2022-04-05 01:41:40.645 INFO 13348 --- [main] io.undertow.servlet : Initializing Spring embedded WebApplicationContext
2022-04-05 01:41:40.646 INFO 13348 --- [main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 4875 ms
2022-04-05 01:41:41.295 WARN 13348 --- [main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaConfiguration': Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Hikari.class]: Unsatisfied dependency expressed through method 'dataSource' parameter 0; nested exception is org.springframework.boot.context.properties.ConfigurationPropertiesBindException: Error creating bean with name 'spring.datasource-org.springframework.boot.autoconfigure.jdbc.DataSourceProperties': Could not bind properties to 'DataSourceProperties' : prefix=spring.datasource, ignoreInvalidFields=false, ignoreUnknownFields=true; nested exception is org.springframework.boot.context.properties.bind.BindException: Failed to bind properties under 'spring.datasource.password' to java.lang.String
2022-04-05 01:41:41.313 INFO 13348 --- [main] ConditionEvaluationReportLoggingListener :
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2022-04-05 01:41:41.357 ERROR 13348 --- [main] o.s.b.d.LoggingFailureAnalysisReporter :
APPLICATION FAILED TO START
Description:
Failed to bind properties under 'spring.datasource.password' to java.lang.String:
Reason: org.springframework.boot.context.properties.bind.BindException: Failed to bind properties under 'spring.datasource.password' to java.lang.String
Action:
Update your application's configuration
2022-04-05 01:41:41.359 WARN 13348 --- [Thread-15] c.a.nacos.common.notify.NotifyCenter : [NotifyCenter] Start destroying Publisher
2022-04-05 01:41:41.359 WARN 13348 --- [Thread-7] c.a.n.common.http.HttpClientBeanHolder : [HttpClientBeanHolder] Start destroying common HttpClient
2022-04-05 01:41:41.360 WARN 13348 --- [Thread-15] c.a.nacos.common.notify.NotifyCenter : [NotifyCenter] Destruction of the end
反复试过多次,代码运行正常,并不存在你说的问题。建议根据以下说明,对照在线文档的操作步骤,看看具体是自己那一步没有走对。
jasypt 主要用途是对 Spring Boot 中,敏感配置信息进行加密和解密。比如,数据库密码为 123456,即使放在 Nacos 配置中,也是一目了然。利用 jasypt 可以对其进行加密,以保证其隐秘性。同时,代码读取该配置之前 jasypt 会对其进行解密以保证使用。jasypt 只是根据配置中的值是否包裹了ENC()
来判断是否需要对该配置进行加解密。将该配置直接写成明文,不包含ENC()
,jasypt 将跳过对该配置的处理。换句话说,将数据库的用户名和密码直接写成你自己的,比如:用户名改成 aaa,密码改成 123456,就可以跳过jasypt,也可以通过这个方法判断是否是由 jasypt影响。
日志里面有一句:
'spring.datasource-org.springframework.boot.autoconfigure.jdbc.DataSourceProperties': Could not bind properties to 'DataSourceProperties'
这说明,服务在启动过程中,没有读取到必须要的配置,即使读取的内容是错的,也要先保证能够读取到。
而工程中,大多数配置都是写在 Nacos 里面,通过 Nacos Config进行读取。很有可能是配置没有修改对,或者操作步骤不对,导致nacos没有正确连接,或者配置没有读取到。
建议按照以下说明尝试解决:
因为是第一次搭建环境,建议按照文档只修改必须要修改的内容,等环境运行起来之后,对整个项目已经有所了解再根据自己的实际需求进行修改,这样可以规避很多不必要的问题。在搭建环境过程中,目前需要修改的配置只有 根目录下的 pom.xml 和 eurynome-cloud-environment.yml(这里有三个文件,主要涉及多环境处理,可以详细看看在线文档的多环境章节)。其它配置文件先不要动手修改,如果有修改最好还原回来。
Nacos 启动以后,访问 http://localhost:8848, 用 nacos 和 nacos 登录,看看能不能登录。
如果 Nacos 可以正常运行,在 eurynome-cloud-monitor 目录下,找到默认配置,导入到 nacos 中。无须一个一个导入,有导入包。
在 idea 中,看看你所选择的 多环境(profile)是否正确。(具体可以详见 在线文档 多环境章节)
在其中修改对应的 Nacos的地址。(如果你在Nacos中,使用了namespace,记得同时修改config.namespace 配置)
如果 idea 中,看看你所选择的多环境是development,那么对应的就修改 nacos 下,group为development的 eurynome-cloud-environment.yml (只修改这个里面的内容即可)
再次启动服务,如果配置正确,同时能够读取到Nacos中的配置。服务就可以正常启动。
启动发现三条警告,提示DEFAULT_GROUP组下面没有这三个yml,使用imports目录配置包自动导入nacos,没有新建过DEFAULT_GROUP,手动建了一下,启动依然报错Could not bind properties to 'DataSourceProperties'
2022-04-07 00:57:02.158 WARN 16144 --- [ main] c.a.c.n.c.NacosPropertySourceBuilder : Ignore the empty nacos configuration and get it based on dataId[eurynome-cloud-upms-ability] & group[DEFAULT_GROUP]
2022-04-07 00:57:02.166 WARN 16144 --- [ main] c.a.c.n.c.NacosPropertySourceBuilder : Ignore the empty nacos configuration and get it based on dataId[eurynome-cloud-upms-ability.yaml] & group[DEFAULT_GROUP]
2022-04-07 00:57:02.171 WARN 16144 --- [ main] c.a.c.n.c.NacosPropertySourceBuilder : Ignore the empty nacos configuration and get it based on dataId[eurynome-cloud-upms-ability-development.yaml] & group[DEFAULT_GROUP]
先给你点个赞吧,开源平台大把spring框架,这个项目是比较精致的了。
今天仔细试下,我尽量把问题描述准确些,常规解决方法都试过。
除了本地差异化的配置,其他使用默认配置
nacos启动正常,postgreSQL正常,mysql正常,外部可连接
redis正常,zookeeper,kafka正常,我的eureka项目正常运行
pom.xml多环境development活动状态正常,nacos连接
eurynome-cloud-environment.yml配置仅修改端口
数据库链接直接明文,降低jasypt版本等等。。。都试了下问题依旧,应该是读不到配置文件导致!
monitorApp能够正常启动注册nacos服务,upmsApp无法启动。。。
也试了下eurynome-cloud-athena,单体版居然正常启动!!!
另配置文件导入nacos,查了库eurynome-cloud-database.yaml会被默认为text(见.metadata.yml)
根据你的描述,现在已经可以明确是配置文件读取不正确。
先说一下 eurynome-cloud-database.yaml会被默认为text的问题,这个问题是因为之前使用过 Nacos 的历史版本还原,这个功能不管之前的配置是什么格式,还原回来都会显示成默认格式。但是根据个人经验,这个主要是控制Nacos管理界面配置文件编辑器的,不会影响配置文件的读取。具体读取配置文件的格式,是根据 bootstrap.yml 中, spring.cloud.nacos.config.file-extension 配置决定。如果担心是这个问题影响,可以在 Nacos中直接编辑该配置文件,将其格式修改为 yaml,发布后再尝试。
先说一下本系统配置文件的设计逻辑,了解了这个逻辑可能就更好帮你排查问题。
本系统的中的配置文件,大量使用了 ${} 占位符,就像变量一样在配置文件中共享配置,以实现在统一配置中修改必须参数,无须到处修改的目的。因此,配置文件中是存在读取先后顺序以及占位符变量值传导的关系的。
数据库方面的主要关系逻辑如下(这里仅说数据库相关的)
profile.name
的值,找到 Nacos 中 对应 group 下的 eurynome-cloud-environment.yaml。搭建环境必须要要修改的参数都在这里,只要在这里进行修改即可,其它配置文件都不需要修改。database.type
, 根据这个参数,会找到不同类型数据特殊配置的支持文件(主要是url等特殊内容),比如 设置为 mysql8,就会读取eurynome-cloud-database-mysql8.yaml这个文件。要严格按照上面的顺序,可以看到 bootstrap.yml 中,是严格按照这个顺序的。顺序错误,就会导致 ${} 占位符 找不到对应的配置而出错。
Nacos 是根据名称(DataID)的绝对匹配来寻找配置文件。eurynome-cloud-environment.yaml
这一整串才是完整的DataID。nacos 的配置文件的名字是eurynome-cloud-environment.yaml
, 那么在bootstrap.yml 中也要是eurynome-cloud-environment.yaml
(spring.cloud.nacos.config.file-extension 配置只是指定配置文件的内容格式,不要因为有这个配置,就把eurynome-cloud-environment.yaml
中的 .yaml
删掉,这样是匹配不到的)。如果你是用 imports 目录下的导入包统一导入,除了你提到的 text的问题以外,是不会有名称问题的。有些人是手动导入 configs 目录中的配置,以为 .yaml
只是文件的后缀,在nacos中创建配置文件的时候,就直接写成 eurynome-cloud-environment
这肯定是读取不到的。
检查 根目录下的pom.xml多环境配置中,参数 database.type
的值是否正确。按照上一点所属,这个值是大小写敏感的。比如这个值 是 postgresql,通过这个值就会找到 eurynome-cloud-database-postgresql.yaml
, 如果写成 Postgresql,那么就肯定找不到。
检查 eurynome-cloud-database.yaml 配置是否存在于 Nacos中,特别是对应的 group 是否正确。configs目录下的子目录名就是对应的 group。如果你是使用 导入包就不会存在这个问题。
确认是否只是修改了,eurynome-cloud-environment.yaml 配置,如果对其它配置进行了修改,建议还原回来了。同时检查一下 eurynome-cloud-environment.yaml 中,已经修改配置的缩进是否正确。yml格式是根据缩进来确认层级关系的。
检查一下是否动到了 uaa 和 upms 服务的 bootstrap.yml,如果动到,还是还原回来的。
检查一下 Nacos 中是否创建了 namespace, 如果创建了namespace,同时 eurynome的所有配置,都在这个namespace下,那么就要修改 pom.xml 中的多环境对应下的 config.namespace
。否则也会找不到配置。
很多因素比如修改错误、配置遗漏、动到不该动的地方都会导致系统抛出某个错误,反之只看某个错误想要反推出你具体做过哪些修改是很难的。不是我推脱,而事实就是如此,如果能重现问题当然简单,但是不能重现问题,我只能根据你的描述进行反向推测,换句话就是猜,是很难解决问题的。能有的猜测以及我能预估到的情况,都已经写在上面了,再出错我也无能为力。也请你仔细回忆自己做了哪些修改和操作。最简单的办法就是代码重新检出,nacos配置删掉重新导入。只对 pom.xml 和 eurynome-cloud-environment.yaml 进行修改。
单体版和微服务版,代码逻辑是一模一样的,因为不涉及服务拆分,就仅需要一个数据库就行,单体版就是共用多了微服务版的核心代码搭建起来的。单体版能跑起来,说明代码没问题。那就是配置问题了。
再次仔细调试N遍,问题终于解决,你代码没有问题!!!
日志显示配置文件都加载成功,如下:
INFO 13592 --- [ main] b.c.PropertySourceBootstrapConfiguration : Located property source: [BootstrapPropertySource {name='bootstrapProperties-eurynome-cloud-upms-ability-development.yaml,DEFAULT_GROUP'}, BootstrapPropertySource {name='bootstrapProperties-eurynome-cloud-upms-ability.yaml,DEFAULT_GROUP'}, BootstrapPropertySource {name='bootstrapProperties-eurynome-cloud-upms-ability,DEFAULT_GROUP'}, BootstrapPropertySource {name='bootstrapProperties-eurynome-cloud-upms-ability.yaml,herodotus'}, BootstrapPropertySource {name='bootstrapProperties-eurynome-cloud-kafka.yaml,common'}, BootstrapPropertySource {name='bootstrapProperties-eurynome-cloud-rest.yaml,common'}, BootstrapPropertySource {name='bootstrapProperties-eurynome-cloud-cache.yaml,common'}, BootstrapPropertySource {name='bootstrapProperties-eurynome-cloud-redis.yaml,common'}, BootstrapPropertySource {name='bootstrapProperties-eurynome-cloud-database.yaml,common'}, BootstrapPropertySource {name='bootstrapProperties-eurynome-cloud-database-postgresql.yaml,common'}, BootstrapPropertySource {name='bootstrapProperties-eurynome-cloud-platform.yaml,common'}, BootstrapPropertySource {name='bootstrapProperties-eurynome-cloud-environment.yaml,development'}]
就是报错,于是猜想是不是nacos通信异常或者流量控制,配置文件加载顺序优先级,编译环境。。。各种尝试,发现是nacos准确的说是Spring Cloud Alibaba Sentinel的问题,标记一下给后来者做个提醒
本机JDK1.8,小版本jdk1.8.0_77,Sentinel官网有标记issue
如果规则加载没有生效,有可能是jdk1.8.0_20 版本导致的,
没想1.8.0_77也被误伤,详细链接:
https://github.com/alibaba/spring-cloud-alibaba/issues/759
解决起来太简单换个jdk
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。
登录 后才可以发表评论