当前位置: 首页 > 知识库问答 >
问题:

启动bean时spring boot docker失败

朱令
2023-03-14

我试图把一个Spring启动应用程序放在一个docker容器内,但当我运行它时,我得到这个错误。我看到它是平木的应用程序属性

  .   ____          _            __ _ _

 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \

( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \

 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )

  '  |____| .__|_| |_|_| |_\__, | / / / /

 =========|_|==============|___/=/_/_/_/

 :: Spring Boot ::        (v2.3.1.RELEASE)


2022-04-13 17:21:59.930  INFO 1 --- [           main] com.classicowines.survey.ClassicoWines   : No active profile set, falling back to default profiles: default

2022-04-13 17:22:01.574  INFO 1 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode.

2022-04-13 17:22:02.164  INFO 1 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 573ms. Found 19 JPA repository interfaces.

2022-04-13 17:22:03.091  INFO 1 --- [           main] o.s.cloud.context.scope.GenericScope     : BeanFactory id=86bffc71-aaf5-31b9-a9ba-6946fcbcc005

2022-04-13 17:22:04.309  INFO 1 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8080 (http)

2022-04-13 17:22:04.331  INFO 1 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]

2022-04-13 17:22:04.332  INFO 1 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet engine: [Apache Tomcat/9.0.36]

2022-04-13 17:22:04.441  INFO 1 --- [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext

2022-04-13 17:22:04.442  INFO 1 --- [           main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 4450 ms

2022-04-13 17:22:04.589  WARN 1 --- [           main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.cloud.autoconfigure.RefreshAutoConfiguration$JpaInvokerConfiguration': Invocation of init method failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.boot.autoconfigure.jdbc.DataSourceInitializerInvoker': Invocation of init method failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Hikari.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.zaxxer.hikari.HikariDataSource]: Factory method 'dataSource' threw exception; nested exception is org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationException: Failed to determine a suitable driver class

2022-04-13 17:22:04.593  INFO 1 --- [           main] o.apache.catalina.core.StandardService   : Stopping service [Tomcat]

2022-04-13 17:22:04.628  INFO 1 --- [           main] ConditionEvaluationReportLoggingListener : 


Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.

2022-04-13 17:22:04.634 ERROR 1 --- [           main] o.s.b.d.LoggingFailureAnalysisReporter   : 
    

我在另一个出版物Spring Boot:未能配置数据源:未指定“url”属性,并且无法配置嵌入式数据源

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-data-jpa</artifactId>
    <exclusions>
        <exclusion>
            <groupId>com.zaxxer</groupId>
            <artifactId>HikariCP</artifactId>
        </exclusion>
    </exclusions>
</dependency>
<dependency>
    <groupId>org.apache.tomcat</groupId>
    <artifactId>tomcat-jdbc</artifactId>
    <version>9.0.10</version>
</dependency>

这是我的天赋


spring.datasource.type=com.zaxxer.hikari.HikariDataSource

# configuracion del jpa
spring.jpa.hibernate.ddl-auto=update
spring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgreSQL82Dialect
spring.jpa.properties.hibernate.jdbc.lob.non_contextual_creation=true
spring.jpa.show-sql=true


# HikariCP config - spring.datasource.hikari.*
spring.datasource.hikari.pool-name=pool-hikari-classico
spring.datasource.hikari.maximum-pool-size=10
spring.datasource.hikari.connection-timeout=60000

泊坞窗文件

FROM openjdk:8-jdk-alpine
COPY "./target/MS_ClassicoWinesSurvey-0.0.1-SNAPSHOT.jar" "app.jar"
EXPOSE 8080
ENTRYPOINT ["java","-jar","app.jar"]

共有1个答案

萧凡
2023-03-14

第一点,我收到了这个项目,要放在一个docker中,第二点,当我检查应该托管配置文件的结构时,它们不在那里。

当我检查jar文件时,应用程序.properties和日志.xml文件没有找到,所以它不起作用,我只是将它们添加到数据源文件夹中,它的工作原理,我还必须在应用程序.properties文件中指定日志作为loglog.config=classpath:logback.xml

 类似资料:
  • 我有一个简单的spring启动应用程序,其中有一个兔子发送器和一个接收器。我想编写一些接收器测试,其中我以Junit类规则(RabbitContainerRule)运行rabbitmq docker实例,然后使用rabbitTemplate发送消息,测试验证接收器是否接收到相同的消息。但我得到了以下例外: 如果使用管理控制台在docker实例中手动创建队列(通过在断点处停止),则测试通过。 另外,

  • 从文件夹内部执行“npm start”命令时出现以下错误/ 我在互联网上尝试了多种解决方案,但都无效。

  • 当我运行这个错误时,请帮助我解决这个问题 启动应用程序上下文时出错。要显示条件,请报告启用“调试”后重新运行应用程序。2019-02-11 10:53:55.839错误8804 --- [ restartedMain]o. s. b. d.日志失败分析记者: 应用程序启动失败 说明: com中的字段userDao。实例Spring Security应用程序编程接口。服务UserServiceImp

  • 当我尝试运行spring boot应用程序时,我遇到了以下异常: 组织。springframework。豆。工厂BeanCreationException:创建名为“configurationPropertiesBeans”的bean时出错,该bean在类路径资源[org/springframework/cloud/autoconfigure/ConfigurationPropertiesRebi

  • 升级Springboot版本-2.7.0 ext{springBootVersion='2.7.0'wsdl2javaVersion='0.10'cxfVersion=1'3.4.3'} 云版本:ext{set(“springCloudVersion”,“2021.0.3”)} Springfox: //swagger编译" io . spring fox:spring fox-swagger 2

  • 我正试图在设备上启动我的应用程序。它正在模拟器上成功发射。 null null 会不会是带有代码签名的东西? 目前我已将其设置为“不编码签名”