Error creating bean with name ‘XXXX‘: Unsatisfied dependency expressed through field

用eclipse写的spring boot的后台程序,在eclipse下正常,打包成jar就不能运行,折腾了好多天,看完了整个互联网上的文章(^-^),也没解决,有一次想改一下Tomcat端口,无意间发现,发现运行jar包时,端号还是默认的8080,才意识到问题的根源时没有加载到application.properties,才导致的“Failed to configure a DataSource: 'url' attribute is not specified and....”,错误,

代码:

<resources>
            <!--解决mybatis-generator-maven-plugin运行时没有将jdbc.properites文件放入target文件夹的问题 -->
            <resource>
                <directory>src/main/resources</directory>
                <includes>
                    <include>*.properties</include>
                    <include>*.xml</include>
                </includes>
            </resource>
        </resources>

注意红色部分,我的.properties文件是放在src/main/resources目录下的:

之后就正常了。上传服务器,ok!

错误提示如下:

ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'analystsServiceImpl': Unsatisfied dependency expressed through field 'analystsMapper'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'analystsMapper' defined in URL [jar:file:/D:/myprogram/eclipse-jee-2020-12-R-win32-x86_64/liu/Java/SpringBoot_Back/target/analysts.jar!/BOOT-INF/classes!/com/analysts/mapper/AnalystsMapper.class]: Unsatisfied dependency expressed through bean property 'sqlSessionFactory'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'sqlSessionFactory' defined in class path resource [org/mybatis/spring/boot/autoconfigure/MybatisAutoConfiguration.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 [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Hikari.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.zaxxer.hikari.HikariDataSource]: Factory method 'dataSource' threw exception; nested exception is org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationException: Failed to determine a suitable driver class

2021-06-25 17:00:16.788  INFO 15776 --- [           main] o.apache.catalina.core.StandardService   : Stopping service [Tomcat]

2021-06-25 17:00:16.818  INFO 15776 --- [           main] ConditionEvaluationReportLoggingListener :

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.

2021-06-25 17:00:16.849 ERROR 15776 --- [           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).

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值