java - 在 Docker 容器上运行时创建名称为 'org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration' 的 bean 时出错

标签 java spring docker spring-boot

我创建了 spring boot 项目,如果我在本地运行,它运行良好。但是,当我 dockerize 这个应用程序并在 Docker 容器中运行它时。问题发生在 Error Creating bean with name 'org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration'

application.properties

spring.datasource.jdbc-url=xxx
spring.datasource.username=xxx
spring.datasource.password=xxx
spring.datasource.driver-class-name=org.postgresql.Driver
spring.datasource.maximum-pool-size=100
spring.datasource.testWhileIdle=true
spring.datasource.validationQuery=SELECT 1
spring.jpa.hibernate.naming.implicit-strategy=org.hibernate.boot.model.naming.ImplicitNamingStrategyLegacyHbmImpl
spring.jpa.hibernate.naming.physical-strategy=org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategy
spring.jpa.hibernate.ddl-auto=update
spring.jpa.database-platform=org.hibernate.dialect.PostgreSQLDialect
spring.jpa.generate-ddl=true
spring.jpa.show-sql=true
spring.jpa.properties.hibernate.default_schema=public
spring.jpa.properties.hibernate.temp.use_jdbc_metadata_defaults=false

Dockerfile

FROM openjdk:8-jdk
COPY target/app-*.jar /app.jar
EXPOSE 8080/tcp
ENTRYPOINT ["java", "-jar", "/app.jar"]

错误:

2018-08-29 03:56:06.093  WARN 1 --- [           main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaConfiguration': Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'authorizationServerConfiguration': Unsatisfied dependency expressed through field 'authenticationManager'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'webSecurityConfiguration': Unsatisfied dependency expressed through field 'partyPlusUserDetailsService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'partyPlusUserDetailsService' defined in URL [jar:file:/app.jar!/BOOT-INF/classes!/com/datnt/pplus/service/user/PartyPlusUserDetailsService.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userRepository': Cannot create inner bean '(inner bean)#71238fc2' of type [org.springframework.orm.jpa.SharedEntityManagerCreator] while setting bean property 'entityManager'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)#71238fc2': Cannot resolve reference to bean 'entityManagerFactory' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name 'entityManagerFactory': Requested bean is currently in creation: Is there an unresolvable circular reference?
2018-08-29 03:56:06.099  INFO 1 --- [           main] o.apache.catalina.core.StandardService   : Stopping service [Tomcat]
2018-08-29 03:56:06.140  INFO 1 --- [           main] ConditionEvaluationReportLoggingListener : 

谁能帮我解决这个问题?

最佳答案

检查“application.properties”并将其放在文件夹“src/main/resources”中

关于java - 在 Docker 容器上运行时创建名称为 'org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration' 的 bean 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52069406/

相关文章:

java - 无法在 Mac 上安装 Glassfish。它表示指定的目录不是有效的 GlassFish 安装

java - 使用 Java 创建 kafka 主题不起作用

java - Autowired 在自定义注销处理程序和自定义用户详细信息中给出 null

java - Servlet Controller - 带参数重定向

docker - 使用Docker API启动容器

docker - 在 Jenkins 容器中运行 docker 容器,如何设置主机的音量?

java - 用java创建一个循环正方形

java - 我可以将 cobertura 报告导出为 Excel 文件吗?

java - CSS 背景属性在使用 java 的 pdfHTML iText7 中不起作用

docker - 无法在Windows 10上减小Docker最大磁盘镜像大小