Witam, mam problem z podpięciem hibernate 5 do spring boota 1.4. Wszystko robie bez pliku persistence.xml w Gradle. Próbowałem już na różne sposoby, niestety w internecie są stare rozwiązania, albo źle szukam :D W tym przypadku dostaję NullPointerException
build.gradle (tylko dependencies)
dependencies {
compile('org.springframework.boot:spring-boot-starter-actuator')
compile('org.springframework.boot:spring-boot-starter-aop')
compile('org.springframework.boot:spring-boot-starter-web')
compile('org.springframework.boot:spring-boot-starter-web-services')
compile "org.jsoup:jsoup:1.9.2"
compile group: 'postgresql', name: 'postgresql', version: '9.1-901-1.jdbc4'
compile group: 'org.hsqldb', name: 'hsqldb', version: '2.3.1'
compile group: 'org.hibernate', name: 'hibernate-core', version: '5.2.2.Final'
testCompile('org.springframework.boot:spring-boot-starter-test')
}
application.properties
spring.datasource.url=jdbc:postgresql://localhost:5432/ernest
spring.datasource.username=postgres
spring.datasource.password=psql
spring.datasource.driver-class-name=org.postgresql.Driver;
spring.jpa.properties.hibernate.format_sql=true
spring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl
UserDao (tu mam NullPointerException w entityManager.persist(user);
import javax.persistence.EntityManager;
import javax.persistence.PersistenceUnit;
import org.springframework.stereotype.Repository;
@Repository
public class UserDao {
@PersistenceUnit
private EntityManager entityManager;
public void saveUser(){
User user = new User();
user.setLogin("ernest");
user.setPassword("pass");
entityManager.persist(user);
}
}
w klasie mainowej mam tylko adnotacje @SpringBootApplication