Springboot 启动莫名的报了一个错误
'sqlSessionFactory'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'sqlSessionFactory' defined in class path resource [com/baomidou/mybatisplus/autoconfigure/MybatisPlusAutoConfiguration.class]: Unsatisfied dependency expressed through method 'sqlSessionFactory' parameter 0; 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 suitable jdbc url
2022-12-15 10:18:58.862 INFO 19844 --- [ main] ConditionEvaluationReportLoggingListener :
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2022-12-15 10:18:58.867 ERROR 19844 --- [ 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 suitable jdbc url
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 (the profiles dev are currently active).
起因是从一个大的springboot项目中的拆分出一个微服务,代码层面确认过是没问题,但启动就是报找不到url,排查了很久都没发现那里不对,然后使用package打包代码,才发现生成的内容不是jar。解决方式也很简单,就是创建pom的时候使用的是pom的方式。
<package>pom</package>
修改为jar
<package>jar</package>
本文来自博客园,作者:三丝柚,转载请注明原文链接:https://www.cnblogs.com/sansyou/p/17533826.html

浙公网安备 33010602011771号