Я настроил свой eureka discovery server
, и он работает на локальном хосте http:\\localhost:8761
. Но когда я пытаюсь настроить eureka discovery client
(в другом проекте в intellij), он был собран правильно, но приложение не запускается и выдает следующую ошибку.
Пожалуйста, найдите трассировку стека ниже.
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.1.6.RELEASE)
2020-07-13 07:12:37.271 INFO 14932 --- [ main] c.l.m.s.c.CoreServicesApplication : Starting CoreServicesApplication on DESKTOP-5ENMOJ0 with PID 14932 (D:\AngularCourse\core-services\out\production\classes started by Karthikeyan in D:\AngularCourse\core-services)
2020-07-13 07:12:37.277 INFO 14932 --- [ main] c.l.m.s.c.CoreServicesApplication : No active profile set, falling back to default profiles: default
2020-07-13 07:12:39.277 INFO 14932 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data repositories in DEFAULT mode.
2020-07-13 07:12:39.430 INFO 14932 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 134ms. Found 3 repository interfaces.
2020-07-13 07:12:39.611 WARN 14932 --- [ main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.support.BeanDefinitionOverrideException: Invalid bean definition with name 'eurekaRegistration' defined in class path resource [org/springframework/cloud/netflix/eureka/EurekaClientAutoConfiguration$EurekaClientConfiguration.class]: Cannot register bean definition [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.cloud.netflix.eureka.EurekaClientAutoConfiguration$EurekaClientConfiguration; factoryMethodName=eurekaRegistration; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/cloud/netflix/eureka/EurekaClientAutoConfiguration$EurekaClientConfiguration.class]] for bean 'eurekaRegistration': There is already [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.cloud.netflix.eureka.EurekaClientAutoConfiguration$RefreshableEurekaClientConfiguration; factoryMethodName=eurekaRegistration; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/cloud/netflix/eureka/EurekaClientAutoConfiguration$RefreshableEurekaClientConfiguration.class]] bound.
2020-07-13 07:12:39.630 INFO 14932 --- [ main] ConditionEvaluationReportLoggingListener :
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2020-07-13 07:12:39.632 ERROR 14932 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter :
***************************
APPLICATION FAILED TO START
***************************
Description:
The bean 'eurekaRegistration', defined in class path resource [org/springframework/cloud/netflix/eureka/EurekaClientAutoConfiguration$EurekaClientConfiguration.class], could not be registered. A bean with that name has already been defined in class path resource [org/springframework/cloud/netflix/eureka/EurekaClientAutoConfiguration$RefreshableEurekaClientConfiguration.class] and overriding is disabled.
Action:
Consider renaming one of the beans or enabling overriding by setting spring.main.allow-bean-definition-overriding=true
Process finished with exit code 1
Найдите мой файл build.gradle
.
plugins {
id 'org.springframework.boot' version '2.1.6.RELEASE'
id 'io.spring.dependency-management' version '1.0.9.RELEASE'
id 'java'
id 'war'
}
group = 'com.lti.mod.services'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '1.8'
configurations {
compileOnly {
extendsFrom annotationProcessor
}
}
repositories {
mavenCentral()
}
dependencies {
implementation('io.jsonwebtoken:jjwt:0.9.1')
implementation('org.springframework.cloud:spring-cloud-netflix-eureka-server:2.1.5.RELEASE')
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-data-rest'
implementation 'org.springframework.boot:spring-boot-starter-security'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.liquibase:liquibase-core'
/*compile group: 'io.jsonwebtoken', name: 'jjwt', version: '0.9.1'*/
compileOnly 'org.projectlombok:lombok'
runtimeOnly 'mysql:mysql-connector-java'
annotationProcessor 'org.projectlombok:lombok'
providedRuntime 'org.springframework.boot:spring-boot-starter-tomcat'
testImplementation('org.springframework.boot:spring-boot-starter-test') {
exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
}
testImplementation 'org.springframework.security:spring-security-test'
}
test {
useJUnitPlatform()
}
Найдите мой файл application.properties
.
spring.application.name=core-services
#datasource
spring.datasource.url=jdbc:mysql://localhost:3306/moddb?useUnicode=true&useLegacyDatetimeCode=false&serverTimezone=UTC&createDatabaseIfNotExist=true&allowPublicKeyRetrieval=true&userSSL=true
spring.datasource.username=root
spring.datasource.password=root
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.jpa.hibernate.ddl-auto=none
#liquibase
spring.liquibase.change-log=classpath:/db/changelog/db.changelog-master.xml
#jwt
app.jwt.secret=RandomSecretKey
#1 day
app.jwt.expiration-in-ms=86400000
app.jwt.token.prefix=Bearer
app.jwt.header.string=Authorization
#eureka
eureka.client.servie-url.default-zone=http://localhost:8761
#indicates the frequency the client sends heartbeat to server to indicate that it is alive.
eureka.instance.lease-renewal-interval-in-seconds=30
#incicates the duration the server waits since it received the last heartbeat before it can evict an instance from its registry
eureka.instance.lease-expiration-duration-in-seconds=90
#load balancing
ribbon.eureka.enabled=true