spirngboot升级后,本地项目加载不到服务器的configmap解决方案

报错信息如下:

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::                (v2.6.8)

[2023-03-31 20:09:59.834] [main] [WARN] [org.springframework.cloud.kubernetes.commons.profile.AbstractKubernetesProfileEnvironmentPostProcessor]  - Not running inside kubernetes. Skipping 'kubernetes' profile activation.
[2023-03-31 20:09:59.838] [main] [INFO] [cn.co.Application]  - The following 1 profile is active: "KUBERNETES_SERVICE_HOST"
[2023-03-31 20:10:00.777] [main] [INFO] [org.springframework.data.repository.config.RepositoryConfigurationDelegate]  - Multiple Spring Data modules found, entering strict repository configuration mode!
[2023-03-31 20:10:00.778] [main] [INFO] [org.springframework.data.repository.config.RepositoryConfigurationDelegate]  - Bootstrapping Spring Data Redis repositories in DEFAULT mode.
[2023-03-31 20:10:00.797] [main] [INFO] [org.springframework.data.repository.config.RepositoryConfigurationDelegate]  - Finished Spring Data repository scanning in 12 ms. Found 0 Redis repository interfaces.
[2023-03-31 20:10:01.063] [main] [INFO] [org.springframework.cloud.context.scope.GenericScope]  - BeanFactory id=e08343d1-81be-30fc-93e7-971edfcfeb5d
[2023-03-31 20:10:01.596] [main] [INFO] [org.springframework.boot.web.embedded.tomcat.TomcatWebServer]  - Tomcat initialized with port(s): 8080 (http)
[2023-03-31 20:10:01.601] [main] [INFO] [org.apache.coyote.http11.Http11NioProtocol]  - Initializing ProtocolHandler ["http-nio-8080"]
[2023-03-31 20:10:01.602] [main] [INFO] [org.apache.catalina.core.StandardService]  - Starting service [Tomcat]
[2023-03-31 20:10:01.602] [main] [INFO] [org.apache.catalina.core.StandardEngine]  - Starting Servlet engine: [Apache Tomcat/9.0.63]
[2023-03-31 20:10:01.705] [main] [INFO] [org.apache.catalina.core.ContainerBase.[Tomcat].[localhost].[/]]  - Initializing Spring embedded WebApplicationContext
[2023-03-31 20:10:01.705] [main] [INFO] [org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext]  - Root WebApplicationContext: initialization completed in 1852 ms
[2023-03-31 20:10:02.038] [main] [WARN] [org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext]  - Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'agencyController' defined in file [/Users/qiaogongzi/target/classes/cn/controller/AgencyController.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'agencyService' defined in file [/Users/qiaogongzi/target/classes/cn/t/service/AgencyService.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'agencyDao' defined in file [/Users/target/classes/cn/c/master/AgencyDao.class]: Cannot resolve reference to bean 'accountMasterSqlSessionFactory' while setting bean property 'sqlSessionFactory'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'accountMasterSqlSessionFactory' defined in class path resource [cn/c/AccountMasterDataSourceConfig.class]: Unsatisfied dependency expressed through method 'sqlSessionFactory' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'accountMasterDataSource' defined in class path resource [cn//AccountMasterDataSourceConfig.class]: Invocation of init method failed; nested exception is org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationException: Failed to determine a suitable driver class
[2023-03-31 20:10:02.041] [main] [INFO] [org.apache.catalina.core.StandardService]  - Stopping service [Tomcat]
[2023-03-31 20:10:02.079] [main] [INFO] [org.springframework.boot.autoconfigure.logging.ConditionEvaluationReportLoggingListener]  - 

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
[2023-03-31 20:10:02.089] [main] [ERROR] [org.springframework.boot.diagnostics.LoggingFailureAnalysisReporter]  - 

***************************
APPLICATION FAILED TO START
***************************

Description:

Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.

解决方案一:

1、ktctl:0.3.7

2、服务配置:

spring:
  main:
    cloud-platform: kubernetes

文档链接:Spring Boot Reference Documentation

方案二:

1、ktctl:0.3.7

2、环境变量中配置HOST和PORT

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值