springboot多环境配置启动报错问题记录

先上一下项目多配置结构

 

当我想要启动项目的时候就报错了,日志如下:

2019-09-16 17:06:59.649  INFO 2253 --- [           main] com.tj.activity.ActivityApplication      : No active profile set, falling back to default profiles: default
2019-09-16 17:06:59.665  INFO 2253 --- [           main] ConfigServletWebServerApplicationContext : Refreshing org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@7048f722: startup date [Mon Sep 16 17:06:59 CST 2019]; parent: org.springframework.context.annotation.AnnotationConfigApplicationContext@2e2ff723
2019-09-16 17:07:00.587  INFO 2253 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Multiple Spring Data modules found, entering strict repository configuration mode!
2019-09-16 17:07:00.930  INFO 2253 --- [           main] f.a.AutowiredAnnotationBeanPostProcessor : JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
2019-09-16 17:07:01.082  INFO 2253 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$b2cadaf5] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2019-09-16 17:07:01.259  INFO 2253 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration' of type [org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration$$EnhancerBySpringCGLIB$$cee4ddf2] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2019-09-16 17:07:01.626  INFO 2253 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8080 (http)
2019-09-16 17:07:01.765  INFO 2253 --- [ost-startStop-1] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 2100 ms
2019-09-16 17:07:02.023  INFO 2253 --- [ost-startStop-1] c.n.c.sources.URLConfigurationSource     : URLs to be used as dynamic configuration source: [file:/Users/utwo/workspace/server/tj-common/tj-util/target/classes/config.properties]
2019-09-16 17:07:02.040  INFO 2253 --- [ost-startStop-1] c.netflix.config.DynamicPropertyFactory  : DynamicPropertyFactory is initialized with configuration sources: com.netflix.config.ConcurrentCompositeConfiguration@212e8d56
2019-09-16 17:07:02.260  INFO 2253 --- [ost-startStop-1] c.a.d.s.b.a.DruidDataSourceAutoConfigure : Init DruidDataSource
2019-09-16 17:07:02.444 ERROR 2253 --- [ost-startStop-1] o.s.b.web.embedded.tomcat.TomcatStarter  : Error starting Tomcat context. Exception: org.springframework.beans.factory.BeanCreationException. Message: Error creating bean with name 'servletEndpointRegistrar' defined in class path resource [org/springframework/boot/actuate/autoconfigure/endpoint/web/ServletEndpointManagementContextConfiguration$WebMvcServletEndpointManagementContextConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.actuate.endpoint.web.ServletEndpointRegistrar]: Factory method 'servletEndpointRegistrar' threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'healthEndpoint' defined in class path resource [org/springframework/boot/actuate/autoconfigure/health/HealthEndpointConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.actuate.health.HealthEndpoint]: Factory method 'healthEndpoint' threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.boot.actuate.autoconfigure.jdbc.DataSourceHealthIndicatorAutoConfiguration': Bean instantiation via constructor failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.actuate.autoconfigure.jdbc.DataSourceHealthIndicatorAutoConfiguration$$EnhancerBySpringCGLIB$$21af2c7b]: Constructor threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [com/alibaba/druid/spring/boot/autoconfigure/DruidDataSourceAutoConfigure.class]: Invocation of init method failed; nested exception is org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationException: Failed to determine a suitable driver class
2019-09-16 17:07:02.473  WARN 2253 --- [           main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.ApplicationContextException: Unable to start web server; nested exception is org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat
2019-09-16 17:07:02.487  INFO 2253 --- [           main] ConditionEvaluationReportLoggingListener : 

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2019-09-16 17:07:02.491 ERROR 2253 --- [           main] o.s.b.d.LoggingFailureAnalysisReporter   : 

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

Description:

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

Reason: Failed to determine a suitable driver class


Action:

Consider the following:
	If you want an embedded database (H2, HSQL or Derby), please put it on the classpath.
	If you have database settings to be loaded from a particular profile you may need to activate it (no profiles are currently active).

Disconnected from the target VM, address: '127.0.0.1:54500', transport: 'socket'

Process finished with exit code 1

刚开始注意是放在这里的

  好吧,英文我也不懂。。。

翻译了一下

百度翻译大佬告诉我未指定配置文件???我一看配置文件都齐全了都呀,怎么提示说未指定呢?瞬间懵逼三连击了

然后我又试着启动了下其他的模块, 结果都是报同样的错误,没有办法了,再看日志吧。。。

我从头再看了一遍日志,这些还真的是发现问题了

17:06:59.649  INFO 2253 --- [           main] com.tj.activity.ActivityApplication      : No active profile set, falling back to default profiles: default

就是这句引起我的注意,我再百度查了几下,但是说的都是什么springboot 2.0版本没有内嵌spring-boot-starter-web包。

但是我查了下我的pom.xml文件是有引入的,很明显不识这个问题了。

最后我从头梳理了一遍springboot配置多环境的步骤,终于让我发现问题了,原来还真的是没有指定那个环境的配置这里出了问题,由于这个项目是直接从git 拉下来的,没有配置指定的文件。。。心好累。。。

好了,既然知道问题出在哪里就好解决了:

新建一个bootstrap.yml 文件,然后写入指定环境的配置就好了

启动成功的日志

好了,解决了问题还是要记录一下的!

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值