报错信息如下:
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: 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