nacos本机模式非虚拟机启动也可正常连接
nacos中的配置中心相当于在application.yml中的相关配置,转移位置,内容同application.yml完全一样均可。
黑马项目导入后,依赖缺失:
[WARNING] The POM for com.baomidou:mybatis-plus-boot-starter:jar:3.4.1 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details
[WARNING] The POM for com.fasterxml.jackson.datatype:jackson-datatype-jsr310:jar:2.11.4 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details
[WARNING] The POM for com.fasterxml.jackson.datatype:jackson-datatype-jdk8:jar:2.11.4 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details
[WARNING] The POM for com.fasterxml.jackson.module:jackson-module-parameter-names:jar:2.11.4 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details
[WARNING] The POM for com.alibaba.cloud:spring-cloud-starter-alibaba-nacos-discovery:jar:2.2.5.RELEASE is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details
[WARNING] The POM for com.alibaba.cloud:spring-cloud-starter-alibaba-nacos-config:jar:2.2.5.RELEASE is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details
尝试在缺失依赖处进行手动导入提示下方错误
2024-01-31 10:46:21.345 [main] WARN o.s.b.w.s.c.AnnotationConfigServletWebServerApplicationContext - Exception encountered during context initialization - cancelling refresh attempt:
提示自动配置失败,refresh方法调用失败org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'apUserLoginController': Unsatisfied dependency expressed through field 'apUserService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'apUserServiceImpl': Unsatisfied dependency expressed through field 'baseMapper'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'apUserMapper' defined in file [D:\project\heima-leadnews\heima-leadnews-service\heima-leadnews-user\target\classes\com\heima\user\mapper\ApUserMapper.class]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Property 'sqlSessionFactory' or 'sqlSessionTemplate' are required
2024-01-31 10:46:21.360 [main] INFO o.a.catalina.core.StandardService - Stopping service [Tomcat]
20 file:/D:/maven/respository/org/apache/hbase/hbase-protocol/2.1.5/hbase-protocol-2.1.5.jar, file:/D:/maven/respository/org/apache/hbase/thirdparty/hbase-shaded-miscellaneous/2.1.0/hbase-shaded-miscellaneous-2.1.0.jar, file:/D:/maven/respository/com/google/protobuf/protobuf-java/3.13.0/protobuf-java-3.13.0.jar, file:/D:/maven/respository/org/apache/hbase/thirdparty/hbase-shaded-netty/2.1.0/hbase-shaded-netty-2.1.0.jar, file:/D:/maven/respository/org/apache/zookeeper/zookeeper/3.4.10/zookeeper-3.4.10.jar, 2/knife4j-spring-boot-starter-2.0.2.jar, file:/D:/maven/respository/com/github/xiaoymin/knife4j-spring-boot-autoconfigure/2.0.2/knife4j-spring-boot-autoconfigure-2.0.2.jar, file:/D:/maven/respository/com/github/xiaoymin/knife4j-spring/2.0.2/knife4j-spring-2.0.2.jar, file:/D:/maven/respository/com/github/xiaoymin/knife4j-annotations/2.0.2/knife4j-annotations-2.0.2.jar, file:/D:/maven/respository/com/github/xiaoymin/knife4j-core/2.0.2/knife4j-core-2.0.2.jar, file:/D:/maven/respository/io/springfox/springfox-bean-validators/2.9.2/springfox-bean-validators-2.9.2.jar, file:/D:/maven/respository/com/github/xiaoymin/knife4j-spring-ui/2.0.2/knife4j-spring-ui- file:/D:/maven/respository/org/apache/tomcat/embed/tomcat-embed-core/9.0.43/tomcat-embed-core-9.0.43.jar, file:/D:/maven/respository/org/glassfish/jakarta.el/3.0.3/jakarta.el-3.0.3.jar, file:/D:/maven/respository/org/apache/tomcat/embed/tomcat-embed-websocket/9.0.43/tomcat-embed-websocket-9.0.43.jar, -slf4j-1.7.30.jar, file:/D:/maven/respository/org/projectlombok/lombok/1.18.8/lombok-1.18.8.jar, file:/D:/Software/IntelliJ%20IDEA%202021.2.1/lib/idea_rt.jar]
2024-01-31 10:46:21.392 [main] DEBUG o.s.b.a.l.ConditionEvaluationReportLoggingListener -
============================
CONDITIONS EVALUATION REPORT :条件评估报告,下方的自动配置可能失效
============================
Positive matches:
-----------------AopAutoConfiguration matched:
- @ConditionalOnProperty (spring.aop.auto=true) matched (OnPropertyCondition)AopAutoConfiguration.ClassProxyingConfiguration matched:
- @ConditionalOnMissingClass did not find unwanted class 'org.aspectj.weaver.Advice' (OnClassCondition)
- @ConditionalOnProperty (spring.aop.proxy-target-class=true) matched (OnPropertyCondition)AuditEventsEndpointAutoConfiguration matched:
- @ConditionalOnAvailableEndpoint no property management.endpoint.auditevents.enabled found so using endpoint default; @ConditionalOnAvailableEndpoint marked as exposed by a 'management.endpoints.jmx.exposure' property (OnAvailableEndpointCondition)CommonsClientAutoConfiguration.DiscoveryLoadBalancerConfiguration matched:
- @ConditionalOnClass found required class 'org.springframework.boot.actuate.health.HealthIndicator' (OnClassCondition)
- @ConditionalOnProperty (spring.cloud.discovery.enabled) matched; @ConditionalOnProperty (spring.cloud.discovery.blocking.enabled) matched (OnPropertyCondition)
- @ConditionalOnBean (types: org.springframework.cloud.client.discovery.DiscoveryClient; SearchStrategy: all) found beans 'nacosDiscoveryClient', 'simpleDiscoveryClient', 'compositeDiscoveryClient' (OnBeanCondition)CommonsClientAutoConfiguration.DiscoveryLoadBalancerConfiguration#discoveryClientHealthIndicator matched:
- @ConditionalOnProperty (spring.cloud.discovery.client.health-indicator.enabled) matched (OnPropertyCondition)CommonsClientAutoConfiguration.DiscoveryLoadBalancerConfiguration#discoveryCompositeHealthContributor matched:
- @ConditionalOnProperty (spring.cloud.discovery.client.composite-indicator.enabled) matched (OnPropertyCondition)
- @ConditionalOnBean (types: org.springframework.cloud.client.discovery.health.DiscoveryHealthIndicator; SearchStrategy: all) found bean 'discoveryClientHealthIndicator' (OnBeanCondition)CompatibilityVerifierAutoConfiguration matched:
- @ConditionalOnProperty (spring.cloud.compatibility-verifier.enabled) matched (OnPropertyCondition)CompositeMeterRegistryAutoConfiguration matched:
- @ConditionalOnClass found required class 'io.micrometer.core.instrument.composite.CompositeMeterRegistry' (OnClassCondition)ConditionsReportEndpointAutoConfiguration matched:
- @ConditionalOnAvailableEndpoint no property management.endpoint.conditions.enabled found so using endpoint default; @ConditionalOnAvailableEndpoint marked as exposed by a 'management.endpoints.jmx.exposure' property (OnAvailableEndpointCondition)ConditionsReportEndpointAutoConfiguration#conditionsReportEndpoint matched:
- @ConditionalOnMissingBean (types: org.springframework.boot.actuate.autoconfigure.condition.ConditionsReportEndpoint; SearchStrategy: current) did not find any beans (OnBeanCondition)ConfigurationPropertiesReportEndpointAutoConfiguration matched:
- @ConditionalOnAvailableEndpoint no property management.endpoint.configprops.enabled found so using endpoint default; @ConditionalOnAvailableEndpoint marked as exposed by a 'management.endpoints.jmx.exposure' property (OnAvailableEndpointCondition)ConfigurationPropertiesReportEndpointAutoConfiguration#configurationPropertiesReportEndpoint matched:
- @ConditionalOnMissingBean (types: org.springframework.boot.actuate.context.properties.ConfigurationPropertiesReportEndpoint; SearchStrategy: all) did not find any beans (OnBeanCondition)DiskSpaceHealthContributorAutoConfiguration matched:
- @ConditionalOnEnabledHealthIndicator management.health.defaults.enabled is considered true (OnEnabledHealthIndicatorCondition)DiskSpaceHealthContributorAutoConfiguration#diskSpaceHealthIndicator matched:
- @ConditionalOnMissingBean (names: diskSpaceHealthIndicator; SearchStrategy: all) did not find any beans (OnBeanCondition)DispatcherServletAutoConfiguration matched:
- @ConditionalOnClass found required class 'org.springframework.web.servlet.DispatcherServlet' (OnClassCondition)
- found 'session' scope (OnWebApplicationCondition)DispatcherServletAutoConfiguration.DispatcherServletConfiguration matched:
- @ConditionalOnClass found required class 'javax.servlet.ServletRegistration' (OnClassCondition)
- @ConditionalOnClass found required class 'org.springframework.http.converter.json.Jackson2ObjectMapperBuilder' (OnClassCondition)JacksonAutoConfiguration.JacksonObjectMapperBuilderConfiguration matched:
- @ConditionalOnClass found required class 'org.springframework.http.converter.json.Jackson2ObjectMapperBuilder' (OnClassCondition)JacksonAutoConfiguration.JacksonObjectMapperBuilderConfiguration#jacksonObjectMapperBuilder matched:
- @ConditionalOnMissingBean (types: org.springframework.http.converter.json.Jackson2ObjectMapperBuilder; SearchStrategy: all) did not find any beans (OnBeanCondition)JacksonAutoConfiguration.JacksonObjectMapperConfiguration matched:
- @ConditionalOnClass found required class 'org.springframework.http.converter.json.Jackson2ObjectMapperBuilder' (OnClassCondition)io.micrometer.core.instrument.binder.jvm.ClassLoaderMetrics; SearchStrategy: all) did not find any beans (OnBeanCondition)
JvmMetricsAutoConfiguration#jvmGcMetrics matched:
CacheMeterBinderProvidersConfiguration.HazelcastCacheMeterBinderProviderConfiguration:
Did not match:
- @ConditionalOnClass did not find required classes 'com.hazelcast.spring.cache.HazelcastCache', 'com.hazelcast.core.Hazelcast' (OnClassCondition)CacheMeterBinderProvidersConfiguration.JCacheCacheMeterBinderProviderConfiguration:
Did not match:
- @ConditionalOnClass did not find required class 'javax.cache.CacheManager' (OnClassCondition)CacheMetricsAutoConfiguration:
- @ConditionalOnWebApplication did not find reactive web application classes (OnWebApplicationCondition)WebSocketServletAutoConfiguration.JettyWebSocketConfiguration:
Did not match:
- @ConditionalOnClass did not find required class 'org.eclipse.jetty.websocket.jsr356.server.deploy.WebSocketServerContainerInitializer' (OnClassCondition)WebSocketServletAutoConfiguration.UndertowWebSocketConfiguration:
Did not match:
- @ConditionalOnClass did not find required class 'io.undertow.websockets.jsr.Bootstrap' (OnClassCondition)XADataSourceAutoConfiguration:
Did not match:
- @ConditionalOnClass did not find required class 'javax.transaction.TransactionManager' (OnClassCondition)
Exclusions: 除外
-----------None
Unconditional classes: 无条件的类
----------------------com.github.tobato.fastdfs.FdfsClientConfig
org.springframework.boot.autoconfigure.availability.ApplicationAvailabilityAutoConfiguration
com.heima.common.exception.ExceptionCatch
org.springframework.boot.autoconfigure.info.ProjectInfoAutoConfiguration
2024-01-31 10:46:21.408 [main] ERROR o.s.boot.SpringApplication - Application run failed
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'apUserLoginController': Unsatisfied dependency expressed through field 'apUserService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'apUserServiceImpl': Unsatisfied dependency expressed through field 'baseMapper'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'apUserMapper' defined in file [D:\project\heima-leadnews\heima-leadnews-service\heima-leadnews-user\target\classes\com\heima\user\mapper\ApUserMapper.class]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Property 'sqlSessionFactory' or 'sqlSessionTemplate' are required
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.resolveFieldValue(AutowiredAnnotationBeanPostProcessor.java:660)
atBean后置增强,注入失败
sqlSessionFactory:每个基于 MyBatis 的应用都是以一个 SqlSessionFactory 的实例为核心的,SqlSessionFactory 的实例可以通过 SqlSessionFactoryBuilder 获得。而 SqlSessionFactoryBuilder 则可以从 XML 配置文件中读取,结合上下文初步推测,未正确读取nacos配置的数据源信息导致
org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:640)
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:119)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessProperties(AutowiredAnnotationBeanPostProcessor.java:399)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1425)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:593)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:516)
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:324)
atProcess finished with exit code 1
Caused by: java.lang.IllegalArgumentException: Property 'sqlSessionFactory' or 'sqlSessionTemplate' are required
at org.springframework.util.Assert.notNull(Assert.java:201)
at org.mybatis.spring.support.SqlSessionDaoSupport.checkDaoConfig(SqlSessionDaoSupport.java:122)
at org.mybatis.spring.mapper.MapperFactoryBean.checkDaoConfig(MapperFactoryBean.java:73)
at org.springframework.dao.support.DaoSupport.afterPropertiesSet(DaoSupport.java:44)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1858)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1795)
... 45 common frames omitted