Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/332.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 定义为;jdbc.properties“;对于mybatis,但仍需要在application.properties中添加spring.datasource?_Java_Database_Spring Boot_Mybatis - Fatal编程技术网

Java 定义为;jdbc.properties“;对于mybatis,但仍需要在application.properties中添加spring.datasource?

Java 定义为;jdbc.properties“;对于mybatis,但仍需要在application.properties中添加spring.datasource?,java,database,spring-boot,mybatis,Java,Database,Spring Boot,Mybatis,我不熟悉春靴和mybatis。我用spring initilizer生成了我的spring boot mybatis项目。 这是我的配置: 应用程序属性 mybatis config.xml 我认为这已经足够了,但是当我运行应用程序时,它会显示错误 SsmApplicationTests > contextLoads() FAILED java.lang.IllegalStateException at DefaultCacheAwareContextLoaderDelegate.

我不熟悉春靴和mybatis。我用spring initilizer生成了我的spring boot mybatis项目。 这是我的配置:

应用程序属性

mybatis config.xml

我认为这已经足够了,但是当我运行应用程序时,它会显示错误

SsmApplicationTests > contextLoads() FAILED
    java.lang.IllegalStateException at DefaultCacheAwareContextLoaderDelegate.java:132
        Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException at ConstructorResolver.java:798
            Caused by: org.springframework.beans.factory.BeanCreationException at ConstructorResolver.java:656
                Caused by: org.springframework.beans.BeanInstantiationException at SimpleInstantiationStrategy.java:185
                    Caused by: org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationException at DataSourceProperties.java:235
但是当我将配置添加到application.properties时。它很好用

spring.datasource.url=jdbc:oracle:thin:@localhost:1521:test
spring.datasource.username=root
spring.datasource.password=root
spring.datasource.driver-class-name=oracle.jdbc.OracleDriver

我真的很困惑,有人知道为什么吗?

应该排除DataSourceAutoConfiguration.class,如下所示:

jdbc.driverClass=oracle.jdbc.OracleDriver
jdbc.url=jdbc:oracle:thin:@localhost:1521:test
jdbc.username=root
jdbc.password=root
SsmApplicationTests > contextLoads() FAILED
    java.lang.IllegalStateException at DefaultCacheAwareContextLoaderDelegate.java:132
        Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException at ConstructorResolver.java:798
            Caused by: org.springframework.beans.factory.BeanCreationException at ConstructorResolver.java:656
                Caused by: org.springframework.beans.BeanInstantiationException at SimpleInstantiationStrategy.java:185
                    Caused by: org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationException at DataSourceProperties.java:235
spring.datasource.url=jdbc:oracle:thin:@localhost:1521:test
spring.datasource.username=root
spring.datasource.password=root
spring.datasource.driver-class-name=oracle.jdbc.OracleDriver