Java 在Tomcat上部署的Spring Boot 2应用程序上找不到/读取Bootstrap.yml
我正在尝试在Tomcat服务器上部署SpringBoot2应用程序。我已经完成了在多个文档中发现的3个步骤,分别是:Java 在Tomcat上部署的Spring Boot 2应用程序上找不到/读取Bootstrap.yml,java,spring-boot,spring-cloud-config,Java,Spring Boot,Spring Cloud Config,我正在尝试在Tomcat服务器上部署SpringBoot2应用程序。我已经完成了在多个文档中发现的3个步骤,分别是: 从SpringBootServletilizer扩展 将嵌入的servlet容器标记为提供的容器 更新包装以适应战争 我遇到的问题是,似乎没有使用放置在src/main/resources上的bootstrap yml文件(如果我以独立的方式运行应用程序,该文件会起作用)。无论我在bootstrap.yml上放置了什么,应用程序总是试图从 17:35:54.193[local
- 从SpringBootServletilizer扩展
- 将嵌入的servlet容器标记为提供的容器
- 更新包装以适应战争
src/main/resources
上的bootstrap yml
文件(如果我以独立的方式运行应用程序,该文件会起作用)。无论我在bootstrap.yml上放置了什么,应用程序总是试图从
17:35:54.193[localhost-startStop-16]信息o.s.c.c.c.ConfigServicePropertySourceLocator-从以下位置的服务器获取配置:
17:35:54.292[localhost-startStop-16]信息o.s.c.c.c.ConfigServicePropertySourceLocator-Url上的连接超时异常-。将尝试下一个url(如果可用)
17:35:54.293[localhost-startStop-16]警告o.s.c.c.c.ConfigServicePropertySourceLocator-找不到PropertySource:获取“”请求时出现I/o错误:连接被拒绝;嵌套异常为java.net.ConnectException:连接被拒绝1
我在另一个线程上读到,我需要对pom具有SpringCloudStarter配置依赖性,但我可以保证我已经拥有了它
这是我使用的bootstrap.yml:
spring:
application:
name : botbrowser
cloud:
config:
uri: http://isblvdivrrd0003:8080 # config-server url
profile: ukdev # environment
label: master
failFast: true
overrideNone: false
overrideSystemProperties: true
enabled: true
allowOverride: true
retry: # connection retrials configuration
initialInterval: 1000 # first timeout
multiplier: 1.5 # factor for subsequence trials (1st trial = initialInterval, 2nd trial = 1st trial * multiplier, ...)
maxAttempts: 6 # number of trials
maxInterval: 5000 # maximal timeout
你知道会发生什么吗
编辑:
包括从pom构建
<build>
<finalName>botbrowser</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>build-info</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.5.3</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<dependencies>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-junit4</artifactId>
<version>2.22.0</version>
</dependency>
</dependencies>
<configuration>
<includes>
<include>**/*.java</include>
</includes>
</configuration>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<executions>
<execution>
<id>pre-unit-test</id>
<goals>
<goal>prepare-agent</goal>
</goals>
<configuration>
<destFile>${project.build.directory}/jacoco.exec</destFile>
<propertyName>surefireArgLine</propertyName>
</configuration>
</execution>
<execution>
<id>post-unit-test</id>
<phase>test</phase>
<goals>
<goal>report</goal>
</goals>
<configuration>
<dataFile>${project.build.directory}/jacoco.exec</dataFile>
<outputDirectory>${project.reporting.outputDirectory}/jacoco-ut</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>pl.project13.maven</groupId>
<artifactId>git-commit-id-plugin</artifactId>
<executions>
<execution>
<id>get-the-git-infos</id>
<goals>
<goal>revision</goal>
</goals>
<!-- <phase>initialize</phase> -->
</execution>
<execution>
<id>validate-the-git-infos</id>
<goals>
<goal>validateRevision</goal>
</goals>
<!-- <phase>package</phase> -->
</execution>
</executions>
<configuration>
<failOnNoGitDirectory>false</failOnNoGitDirectory>
<generateGitPropertiesFile>true</generateGitPropertiesFile>
<generateGitPropertiesFilename>
${project.build.outputDirectory}/git.properties
</generateGitPropertiesFilename>
<verbose>false</verbose>
</configuration>
</plugin>
</plugins>
</build>
僵尸浏览器
org.springframework.boot
springbootmaven插件
构建信息
org.apache.maven.plugins
maven发布插件
2.5.3
org.apache.maven.plugins
maven surefire插件
org.apache.maven.surefire
surefire-junit4
2.22.0
**/*.爪哇
org.jacoco
jacocomaven插件
单元前测试
配制剂
${project.build.directory}/jacoco.exec
surefireArgLine
单元后测试
测试
报告
${project.build.directory}/jacoco.exec
${project.reporting.outputDirectory}/jacoco-ut
pl.project13.maven
git提交id插件
获取git信息
修订
验证git信息
验证视觉
假的
真的
${project.build.outputDirectory}/git.properties
假的
非常感谢您提前请检查bootstrap.yml是否从gradle build的jar/war中排除您是否验证了bootstrap.yml已被复制到您的war中,因此可以在部署时找到?查看您的构建脚本会有所帮助。是的。它在/WEB-INF/classes中。我正在编辑原始答案以添加POM部分,我假设根本没有找到/加载
bootstrap.yml
,即没有使用任何属性。(你可以通过在文件中放入垃圾并重新部署来验证。)你说这一切在使用嵌入式web容器运行时都可以正常工作。。。您可以添加一些调试和重新部署,以便我们可以看到启动时加载/配置了什么吗?好的,我已经将其置于调试和重新部署状态。不确定我必须检查什么,但我已经将独立部署与tomcat部署进行了比较。我看到它在standalone中查找引导,在此之前,它从“configurationProperties”中查找spring.application.name值。在tomcat中,它似乎并不寻找引导,它从“configurationProperties”中获得的唯一值是“spring.aop.proxy-target-class”,您有没有机会分享它?我看到:2019-09-25 15:17:55987调试[main]配置文件应用程序侦听器:加载的配置文件'file:/Users/myservice/target/classes/bootstrap.yml'(classpath:/bootstrap.yml)
和来自configservicebootstrap配置的许多+ve匹配项