1. 程式人生 > >SpringCloud 新增spring-boot-starter-data-jpa後報錯

SpringCloud 新增spring-boot-starter-data-jpa後報錯

小白 學習微服務當中

之前能夠執行,後來不知道怎麼了報錯

重新構建專案後 還是一引入這個就報錯 不知道是哪裡配置出了問題 但是之前並沒有報錯

connnected to the target VM, address: '127.0.0.1:1736', transport: 'socket'

2018-07-18 20:47:24.545  INFO 19252 --- [           main] s.c.a.AnnotationConfigApplicationContext : Refreshing org.spring[email protected]421bba99: startup date [Wed Jul 18 20:47:24 CST 2018]; root of context hierarchy
2018-07-18 20:47:24.789  INFO 19252 --- [           main] f.a.AutowiredAnnotationBeanPostProcessor : JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
2018-07-18 20:47:24.803  INFO 19252 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'configurationPropertiesRebinderAutoConfiguration' of type [org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration$$EnhancerBySpringCGLIB$$5deff870] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::  (v2.1.0.BUILD-SNAPSHOT)

2018-07-18 20:47:25.322  INFO 19252 --- [  main] com.he.product.ProductApplication        : No active profile set, falling back to default profiles: default


2018-07-18 20:47:25.336  INFO 19252 --- [ main] ConfigServletWebServerApplicationContext :

Refreshing org.springframework.boot.web.ser[email protected]680362a: startupdate[WedJul1820:47:25CST2018];parent:org.spring[email protected]421bba99
2018-07-18 20:47:26.113  WARN 19252 --- [main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.support.BeanDefinitionOverrideException:

Invalid bean definition with name 'dataSource' defined in BeanDefinition defined in class path resource

[org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Hikari.class]: Cannot register bean definition [Root bean: class [org.springframework.aop.scope.ScopedProxyFactoryBean]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null; defined in BeanDefinition defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Hikari.class]]

for bean 'dataSource': There is already [Root bean: class [null]; scope=refresh; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=false; primary=false; factoryBeanName=org.springframework.boot.autoconfigure.jdbc.DataSourceConfiguration$Hikari; factoryMethodName=dataSource; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Hikari.class]] bound.
2018-07-18 20:47:26.125  INFO 19252 --- [           main] ConditionEvaluationReportLoggingListener : 

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2018-07-18 20:47:26.135 ERROR 19252 --- [           main] o.s.b.d.LoggingFailureAnalysisReporter   : 

***************************
APPLICATION FAILED TO START
***************************

Description:

The bean 'dataSource', defined in BeanDefinition defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Hikari.class], could not be registered. A bean with that name has already been defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Hikari.class] and overriding is disabled.

Action:

Consider renaming one of the beans or enabling overriding by setting spring.main.allow-bean-definition-overriding=true

Disconnected from the target VM, address: '127.0.0.1:1736', transport: 'socket'

Process finished with exit code 1

這是YML:

spring:
  application:
    name:  product
  datasource:
    driver-class-name: com.mysql.cj.jdbc.Driver
    username: root
    password: 123
    url: jdbc:mysql://Localhost:3306/SpringCloud_Sell?charaterEncoding=utf-8&useSSL=false
  jpa:
    show-sql: true
    database-platform: org.hibernate.dialect.MySQL5Dialect
eureka:
  client:
    service-url:
       defaultZone:  http://localhost:8761/eureka/
server:
  port: 8090

xml:

<?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.he</groupId>
   <artifactId>product</artifactId>
   <version>0.0.1-SNAPSHOT</version>
   <packaging>jar</packaging>

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

   <parent>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-parent</artifactId>
      <version>2.1.0.BUILD-SNAPSHOT</version>
      <relativePath/> <!-- lookup parent from repository -->
   </parent>

   <properties>
      <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
      <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
      <java.version>1.8</java.version>
      <spring-cloud.version>Finchley.BUILD-SNAPSHOT</spring-cloud.version>
   </properties>

   <dependencies>
      <dependency>
         <groupId>org.springframework.cloud</groupId>
         <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
      </dependency>

      <dependency>
         <groupId>org.springframework.boot</groupId>
         <artifactId>spring-boot-starter-test</artifactId>
         <scope>test</scope>
      </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>

        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
        </dependency>

   </dependencies>

   <dependencyManagement>
      <dependencies>
         <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-dependencies</artifactId>
            <version>${spring-cloud.version}</version>
            <type>pom</type>
            <scope>import</scope>
         </dependency>
      </dependencies>
   </dependencyManagement>

   <build>
      <plugins>
         <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
         </plugin>
      </plugins>
   </build>

   <repositories>
      <repository>
         <id>spring-snapshots</id>
         <name>Spring Snapshots</name>
         <url>https://repo.spring.io/snapshot</url>
         <snapshots>
            <enabled>true</enabled>
         </snapshots>
      </repository>
      <repository>
         <id>spring-milestones</id>
         <name>Spring Milestones</name>
         <url>https://repo.spring.io/milestone</url>
         <snapshots>
            <enabled>false</enabled>
         </snapshots>
      </repository>
   </repositories>

   <pluginRepositories>
      <pluginRepository>
         <id>spring-snapshots</id>
         <name>Spring Snapshots</name>
         <url>https://repo.spring.io/snapshot</url>
         <snapshots>
            <enabled>true</enabled>
         </snapshots>
      </pluginRepository>
      <pluginRepository>
         <id>spring-milestones</id>
         <name>Spring Milestones</name>
         <url>https://repo.spring.io/milestone</url>
         <snapshots>
            <enabled>false</enabled>
         </snapshots>
      </pluginRepository>
   </pluginRepositories>


</project>

相關推薦

SpringCloud 新增spring-boot-starter-data-jpa

小白 學習微服務當中 之前能夠執行,後來不知道怎麼了報錯 重新構建專案後 還是一引入這個就報錯 不知道是哪裡配置出了問題 但是之前並沒有報錯 connnected to the target VM, address: '127.0.0.1:1736', transpor

Spring boot集成spring-boot-starter-data-jpa環境搭建

lis ESS hiberna 構建 TP xtend 默認 location col 1、創建Spring boot項目 2、保存等待構建完成 3、增加spring-boot-starter-data-jpa、內存數據庫依賴包hsqldb

springboot2.04 +spring-boot-starter-data-redis 無法war部署

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

springboot2整合elasticsearch6.x(spring-boot-starter-data-elasticsearch)

1.maven依賴 <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-elasticsearc

springBoot redis -- spring-boot-starter-data-redis與spring-boot-starter-redis兩個包的區別

1、下面是Spring Boot的版本為1.5.9的時候的spring-boot-starter-data-redis的jar包的情況: 2、下面是Spring Boot的版本為1.4.0的時候的spring-boot-starter-data-redis的jar包的情

spring-boot-starter-data-redis(spring cloud 操作redis) RedisTemplate

入門: 引入依賴: <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-redis&

完整教程:spring-boot-starter-data-elasticsearch整合elasticsearch 6.x

1、前言 網上很多言論: 新版本的SpringBoot 2的spring-boot-starter-data-elasticsearch中支援的Elasticsearch版本是2.X, 但Elasticsearch實際上已經發展到6.5.X版本了,為了更好的使用Elasticse

談談spring-boot-starter-data-redis序列化

在上一篇中[springboot 2.X 整合redis](https://www.cnblogs.com/homeSicker/p/13177730.html)中提到了在spring-boot-starter-data-redis中使用JdkSerializationRedisSerializerl來實現序

Spring Boot項目Maven Build的解決方法

running ati 依賴 lur fail compile ring date -c 問題1, [ERROR]Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.21.0:tes

spring boot junit測試的時候MockServerContainer does not support addEndpoint

在編寫junit測試spring boot專案的時候報錯MockServerContainer does not support addEndpoint  然自己在@SpringBootTest中加上SpringBootTest.WebEnvironment.RANDOM_PORT成功解決

spring boot 整合第三方簡訊包

2018-09-13 07:36:07,349 WARN [org.springframework.web.context.support.GenericWebApplicationContext] - Exception encountered during context

spring boot + Thymeleaf + layui table 渲染 Could not parse as expression: "

使用的layui的table資料表格模組,然後thymeleaf渲染的時候失敗,報錯的位置提示在 cols:[[...]],就是[[]]裡面的內容不能渲染,後面檢視資料發現是 [[]]是thymelea

spring boot】【elasticsearch】spring boot整合elasticsearch,啟動Caused by: java.lang.IllegalStateException: availableProcessors is already set to [8], reje

  spring boot整合elasticsearch, 啟動報錯: Caused by: java.lang.IllegalStateException: availableProcessors is already set to [8], rejecting [8] at

spring boot 整合shiro 配置類問題

這裡傳入的是下邊返回的自定義Realm,下邊是報錯,報的是該類不能被裝載,由jdk自己裝載,這裡不是太懂,記錄一下,由於錯誤太長,不好截圖,直接複製錯誤內容 >>>>>>>>>>>>>>&

用Qt5.12 Creator嚮導新增新類(class)LNK2019無法解析的外部符號

扣扣技術交流群:460189483   在添加了一個新的class之後就報這個錯,查了好久沒發現程式碼的問題,甚至把原來能編譯通過的class 直接copy過來都還是報錯, main.obj:-1: error: LNK2019: 無法解析的外部符號 "public: _

Spring Boot項目Maven打包(repackage failed: Unable to find main class)

class art 配置 報錯 tin log logs 解決 文件添加 解決方案: setting.xml文件添加如下配置: <plugin> <groupId>org.springframework.boot</group

阿里druid-spring-boot-starter 配置(配置完成不需要在配置類寫)根據阿里官方個人整理

# JDBC 配置(驅動類自動從url的mysql識別,資料來源型別自動識別) # 或spring.datasource.url= spring.datasource.druid.url=jdbc:mysql://192.168.1.1:3306/test?useUnicode=true&c

Spring Boot Starter 的基本封裝

java aop 通過 pac ket oot foundry 支持 cto 1)spring-boot-starter這是Spring Boot的核心啟動器,包含了自動配置、日誌和YAML。 2)spring-boot-starter-amqp通過spring-rabbi

基於Spring Boot,使用JPA動態調用Sql查詢數據

註解 查詢 ldr http autowired dal -c osi 動態 在《基於Spring Boot,使用JPA操作Sql Server數據庫完成CRUD》,《基於Spring Boot,使用JPA調用Sql Server數據庫的存儲過程並返回記錄集合》完成了CRU

spring-boot-starter-actuator(健康監控)配置和使用

frame maven git 追蹤 包括 屬性 per dump zookeepe 在生產環境中,需要實時或定期監控服務的可用性。Spring Boot的actuator(健康監控)功能提供了很多監控所需的接口,可以對應用系統進行配置查看、相關功能統計等。 集成: