Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Java

Spring stopped creating Beans

I am developing a Spring Hibernate application, which was working fine just before trying to implement the Spring security

I added the required dependencies but the app doesn't start, so I tried to update all of them but no difference was made (except that Spring 5 shows the exception in a more friendly way), I'm so lost right now so please if you know the answer comment it out

group 'ah_doc_manag'
version '1.0-SNAPSHOT'

// Include the Spring Boot plugin
buildscript {
    repositories {
        mavenCentral()
        maven { url "https://repo.spring.io/plugins-snapshot" }
        maven { url "https://repo.spring.io/snapshot" }
        maven { url "https://repo.spring.io/milestone" }
    }
    dependencies {
        classpath "io.spring.gradle:dependency-management-plugin:0.6.0.BUILD-SNAPSHOT"
        classpath('org.springframework.boot:spring-boot-gradle-plugin:2.1.2.RELEASE')
    }
}

// Apply the Spring Boot plugin

// Apply the Java plugin (expects src/main/java to be source folder)
apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'org.springframework.boot'

apply plugin: 'war'

jar {
    baseName = 'ahDocManage'
    version = '0.0.1-SNAPSHOT'
}
war {
    baseName = 'ahDocManage'
    version = '0.0.1-SNAPSHOT'
}

// Specify the location where our dependencies will be found
repositories {
    mavenCentral()
}

// Specify dependencies
dependencies {
//    compile 'org.springframework.boot:spring-boot-starter-thymeleaf'
    compile group: 'org.springframework.boot', name: 'spring-boot-starter-thymeleaf', version: '2.1.2.RELEASE'

//    compile 'org.springframework:spring-orm:4.2.5.RELEASE'
    compile group: 'org.springframework', name: 'spring-orm', version: '5.1.4.RELEASE'

    compile group: 'org.springframework.boot', name: 'spring-boot-starter-web', version: '2.1.2.RELEASE'
    compile group: 'org.springframework', name: 'spring-web', version: '5.1.4.RELEASE'
    compile group: 'org.springframework', name: 'spring-webmvc', version: '5.1.4.RELEASE'
    compile group: 'org.springframework.boot', name: 'spring-boot-starter-tomcat', version: '2.1.2.RELEASE'



//    compile 'org.springframework.data:spring-data-jpa:1.9.2.RELEASE'
    compile group: 'org.springframework.data', name: 'spring-data-jpa', version: '2.1.4.RELEASE'

//    compile 'org.hibernate:hibernate-core:5.2.1.Final'
    compile group: 'org.hibernate', name: 'hibernate-core', version: '5.4.1.Final'

//    compile 'org.hibernate:hibernate-entitymanager:5.2.1.Final'
    compile group: 'org.hibernate', name: 'hibernate-entitymanager', version: '5.4.1.Final'

//    compile 'org.apache.tomcat:tomcat-dbcp:8.0.32'
    compile group: 'org.apache.tomcat', name: 'tomcat-dbcp', version: '9.0.14'



//    compile 'org.springframework.boot:spring-boot-starter-security'
    compile group: 'org.springframework.boot', name: 'spring-boot-starter-security', version: '2.1.2.RELEASE'

//    compile 'org.thymeleaf.extras:thymeleaf-extras-springsecurity4:2.1.2.RELEASE'
    compile group: 'org.thymeleaf.extras', name: 'thymeleaf-extras-springsecurity4', version: '3.0.4.RELEASE'

    compile 'com.h2database:h2:1.4.191'

    compile 'org.hashids:hashids:1.0.1'

    providedRuntime 'org.springframework.boot:spring-boot-starter-tomcat'

    compile 'com.itextpdf:itextpdf:5.0.6'


    runtime 'net.sourceforge.nekohtml:nekohtml:1.9.22'


    // https://mvnrepository.com/artifact/javax.validation/validation-api
    compile group: 'javax.validation', name: 'validation-api', version: '1.0.0.GA'

    // https://mvnrepository.com/artifact/javax.servlet/javax.servlet-api
    compileOnly group: 'javax.servlet', name: 'javax.servlet-api', version: '4.0.1'

}

task wrapper(type: Wrapper) {
    gradleVersion = '2.9'
}

This is the build.gradle file. And when I run the app, I get this:

Description:

Field userDao in ah_doc_manag.service.UserServiceImpl required a bean named 'entityManagerFactory' that could not be found.

The injection point has the following annotations:
    - @org.springframework.beans.factory.annotation.Autowired(required=true)

Action:

Consider defining a bean named 'entityManagerFactory' in your configuration.

This keeps coming up even when I add entityManagerFactory another Bean name appears.

Thanks for your help