【Java】Spring boot配置多数据源启动后报注入错误

依赖如下

<?xml version="1.0" encoding="UTF-8"?>

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

<modelVersion>4.0.0</modelVersion>

<groupId>com.mpush.view</groupId>

<artifactId>mpview</artifactId>

<version>0.0.1-SNAPSHOT</version>

<packaging>jar</packaging>

<name>mpview</name>

<description>Demo project for Spring Boot</description>

<parent>

<groupId>org.springframework.boot</groupId>

<artifactId>spring-boot-starter-parent</artifactId>

<version>2.0.0.RELEASE</version>

</parent>

<properties>

<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>

<java.version>1.8</java.version>

</properties>

<dependencies>

<dependency>

<groupId>com.alibaba</groupId>

<artifactId>druid</artifactId>

<version>1.0.18</version>

</dependency>

<dependency>

<groupId>org.springframework.boot</groupId>

<artifactId>spring-boot-starter-jdbc</artifactId>

</dependency>

<dependency>

<groupId>org.springframework.boot</groupId>

<artifactId>spring-boot-starter-thymeleaf</artifactId>

</dependency>

<dependency>

<groupId>org.springframework.boot</groupId>

<artifactId>spring-boot-starter-web</artifactId>

</dependency>

<dependency>

<groupId>org.mybatis.spring.boot</groupId>

<artifactId>mybatis-spring-boot-starter</artifactId>

<version>1.3.1</version>

</dependency>

<dependency>

<groupId>org.springframework.boot</groupId>

<artifactId>spring-boot-starter-test</artifactId>

<scope>test</scope>

</dependency>

<dependency>

<groupId>org.projectlombok</groupId>

<artifactId>lombok</artifactId>

<version>1.16.14</version>

</dependency>

<dependency>

<groupId>org.apache.tomcat</groupId>

<artifactId>tomcat-jdbc</artifactId>

</dependency>

<dependency>

<groupId>com.oracle</groupId>

<artifactId>ojdbc14</artifactId>

<version>1.0.0.0</version>

<scope>system</scope>

<systemPath>${basedir}/lib/ojdbc14.jar</systemPath>

</dependency>

</dependencies>

<build>

<plugins>

<plugin>

<groupId>org.springframework.boot</groupId>

<artifactId>spring-boot-maven-plugin</artifactId>

</plugin>

</plugins>

</build>

<!--<repositories>

<repository>

<id>spring-milestone</id>

<url>http://repo.spring.io/libs-release</url>

</repository>

</repositories>-->

</project>

这里是启动类的注解
【Java】Spring boot配置多数据源启动后报注入错误

其中一个数据源的配置,链接等配置放在了yml配置中

【Java】Spring boot配置多数据源启动后报注入错误

service 方法

【Java】Spring boot配置多数据源启动后报注入错误

如果将dao层注入剥离可以顺利启动

报错信息
【Java】Spring boot配置多数据源启动后报注入错误

【Java】Spring boot配置多数据源启动后报注入错误

mapper扫描也已经配置好

【Java】Spring boot配置多数据源启动后报注入错误

不胜感激!

回答

这个问题已经解决了,最重要的导致错误的dataSource 配置类没有po出来
主要参考的是 http://blog.csdn.net/acquaint...
遇到问题的小伙伴可以参考一下这个博客

以上是 【Java】Spring boot配置多数据源启动后报注入错误 的全部内容, 来源链接: utcz.com/a/90510.html

回到顶部