Spring Boot – repository field required a bean named ‘entityManagerFactory’ that could not be found

原创 Laughing  2019-07-26 01:00  阅读 20 次 评论 0 条
温馨提示

我出现这个问题是因为jar包冲突了

  1. <?xml version="1.0" encoding="UTF-8"?>  
  2. <project xmlns="http://maven.apache.org/POM/4.0.0"  
  3.          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
  4.          xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">  
  5.     <modelVersion>4.0.0</modelVersion>  
  6.   
  7.     <groupId>Net.XiangCaoWuYu.Idea</groupId>  
  8.     <artifactId>Net.XiangCaoWuYu.Idea</artifactId>  
  9.     <version>1.0-SNAPSHOT</version>  
  10.     <packaging>jar</packaging>  
  11.     <name>Net.XiangCaoWuYu.Idea</name>  
  12.     <description>Demo project for Spring Boot</description>  
  13.   
  14.     <parent>  
  15.         <groupId>org.springframework.boot</groupId>  
  16.         <artifactId>spring-boot-starter-parent</artifactId>  
  17.         <version>2.1.6.RELEASE</version>  
  18.     </parent>  
  19.   
  20.     <properties>  
  21.         <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>  
  22.         <start-class>Net.XiangCaoWuYu.App</start-class>  
  23.     </properties>  
  24.   
  25.     <dependencies>  
  26.         <!--开发web项目相关依赖-->  
  27.         <dependency>  
  28.             <groupId>org.springframework.boot</groupId>  
  29.             <artifactId>spring-boot-starter-web</artifactId>  
  30.         </dependency>  
  31.         <!--springboot单元测试-->  
  32.         <dependency>  
  33.             <groupId>org.springframework.boot</groupId>  
  34.             <artifactId>spring-boot-starter-test</artifactId>  
  35.             <scope>test</scope>  
  36.         </dependency>  
  37.         <!-- 添加mysql-->  
  38.         <dependency>  
  39.             <groupId>org.springframework.boot</groupId>  
  40.             <artifactId>spring-boot-starter-jdbc</artifactId>  
  41.         </dependency>  
  42.         <dependency>  
  43.             <groupId>mysql</groupId>  
  44.             <artifactId>mysql-connector-java</artifactId>  
  45.             <scope>runtime</scope>  
  46.         </dependency>  
  47.         <dependency>  
  48.             <groupId>org.springframework.boot</groupId>  
  49.             <artifactId>spring-boot-starter-data-jpa</artifactId>  
  50.         </dependency>  
  51.         <!-- 添加thymeleaf-->  
  52.         <dependency>  
  53.             <groupId>org.springframework.boot</groupId>  
  54.             <artifactId>spring-boot-starter-thymeleaf</artifactId>  
  55.         </dependency>  
  56.         <!-- @Data 编译时自动生成get,set方法,构造函数,toString方法。-->  
  57.         <dependency>  
  58.             <groupId>org.projectlombok</groupId>  
  59.             <artifactId>lombok</artifactId>  
  60.             <version>1.18.8</version>  
  61.             <scope>compile</scope>  
  62.         </dependency>  
  63.         <!--添加fastjson解析JSON数据-->  
  64.         <dependency>  
  65.             <groupId>com.alibaba</groupId>  
  66.             <artifactId>fastjson</artifactId>  
  67.             <version>1.2.16</version>  
  68.         </dependency>  
  69.         <!-- 添加redis-->  
  70.         <dependency>  
  71.             <groupId>org.springframework.boot</groupId>  
  72.             <artifactId>spring-boot-starter-redis</artifactId>  
  73.             <version>1.3.8.RELEASE</version>  
  74.         </dependency>  
  75.         <!--        session依赖-->  
  76.         <dependency>  
  77.             <groupId>org.springframework.session</groupId>  
  78.             <artifactId>spring-session-data-redis</artifactId>  
  79.             <version>1.3.5.RELEASE</version>  
  80.         </dependency>  
  81.         <!--        js国际化插件-->  
  82.         <dependency><!--jQuery国际化插件-->  
  83.             <groupId>org.webjars.bower</groupId>  
  84.             <artifactId>jquery-i18n-properties</artifactId>  
  85.             <version>1.2.7</version>  
  86.         </dependency>  
  87. <!--        与jpa冲突,暂时没解决       添加hibernate&ndash;&gt;-->  
  88. <!--        <dependency>-->  
  89. <!--            <groupId>org.springframework</groupId>-->  
  90. <!--            <artifactId>spring-orm</artifactId>-->  
  91. <!--        </dependency>-->  
  92. <!--        <dependency>-->  
  93. <!--            <groupId>org.hibernate</groupId>-->  
  94. <!--            <artifactId>hibernate-core</artifactId>-->  
  95. <!--            <version>4.3.11.Final</version>-->  
  96. <!--        </dependency>-->  
  97.         <!-- 添加log4j-->  
  98.         <dependency>  
  99.             <groupId>org.springframework.boot</groupId>  
  100.             <artifactId>spring-boot-starter</artifactId>  
  101.             <exclusions>  
  102.                 <exclusion>  
  103.                     <groupId>org.springframework.boot</groupId>  
  104.                     <artifactId>spring-boot-starter-logging</artifactId>  
  105.                 </exclusion>  
  106.             </exclusions>  
  107.         </dependency>  
  108.         <dependency>  
  109.             <groupId>org.springframework.boot</groupId>  
  110.             <artifactId>spring-boot-starter-log4j</artifactId>  
  111.             <version>1.3.8.RELEASE</version>  
  112.         </dependency>  
  113.     </dependencies>  
  114.     <!--maven构建-->  
  115.     <build>  
  116.         <plugins>  
  117.             <plugin>  
  118.                 <groupId>org.springframework.boot</groupId>  
  119.                 <artifactId>spring-boot-maven-plugin</artifactId>  
  120.             </plugin>  
  121.         </plugins>  
  122.     </build>  
  123.   
  124. </project>  

历史上的今天:

本文地址:https://www.lisen.me/spring-boot-repository-field-required-a-bean-named-entitymanagerfactory-that-could-not-be-found.html
版权声明:本文为原创文章,版权归 木子网 所有,欢迎分享本文,转载请保留出处!

发表评论


表情