hapifhir / hapi-fhir

🔥 HAPI FHIR - Java API for HL7 FHIR Clients and Servers
http://hapifhir.io
Apache License 2.0
2.04k stars 1.33k forks source link

[5.1.0] Not able to start server: 'transactionManager' bean could not be registered #2040

Open sergej-reiser opened 4 years ago

sergej-reiser commented 4 years ago

Describe the bug I am using hapi-fhir-spring-boot-starter to run my FHIR-Server. After upgrading my gradle dependencies to HAPI 5.1.0, I am getting the following error when startig the server:

2020-08-13 21:19:30.546 ERROR 1812 --- [           main] o.s.b.d.LoggingFailureAnalysisReporter   : 

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

Description:

The bean 'transactionManager', defined in class path resource [org/springframework/batch/core/configuration/annotation/SimpleBatchConfiguration.class], could not be registered. A bean with that name has already been defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class] and overriding is disabled.

Action:

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

I uploaded a simple project which makes use of hapi-fhir-spring-boot-starter to start a HAPI-Server. You can reproduce the error by cloning https://github.com/sergej-reiser/hapi-issue.git and try to run the spring application yourself. When i change the HAPI dependencies to 5.0.2, the server starts without any issues.

Environment (please complete the following information):

Additional Information: My build.gradle file looks like this:

plugins {
    id 'org.springframework.boot' version '2.3.3.RELEASE'
    id 'io.spring.dependency-management' version '1.0.10.RELEASE'
    id 'java'
    id 'war'
}

group = 'com.example'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '11'

repositories {
    mavenCentral()
}

dependencies {
    implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
    implementation 'org.springframework.boot:spring-boot-starter-web'
    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'
    }

    implementation 'ca.uhn.hapi.fhir:hapi-fhir-spring-boot-starter:5.1.0'   // no issues with 5.0.2
    implementation 'ca.uhn.hapi.fhir:hapi-fhir-jpaserver-base:5.1.0'        // no issues with 5.0.2
    implementation 'ca.uhn.hapi.fhir:hapi-fhir-jaxrsserver-base:5.1.0'      // no issues with 5.0.2

    runtimeOnly 'org.apache.derby:derby'
}

test {
    useJUnitPlatform()
}
sergej-reiser commented 4 years ago

After taking a closer look to hapi-fhir-spring-boot-sample-server-jpa i finally found my issue.

Since HAPI 5.1.0 i need to add the following configurations to my application.yml file:

spring:
  main:
     allow-bean-definition-overriding: true
  batch:
    job:
       enabled: false