[英]Bootstrap.yml not being found/read on Spring Boot 2 application deployed on Tomcat
我正在尝试在 Tomcat 服务器上部署 Spring Boot 2 应用程序。 我已经完成了在多个文档中找到的 3 个步骤,即:
SpringBootServletInitializer
扩展我遇到的问题是,似乎没有使用放置在src/main/resources
上的bootstrap yml
文件(如果我将应用程序作为独立的应用程序运行)。 无论我在bootstrap.yml
上放什么,应用程序总是尝试从http://localhost:8888获取配置
17:35:54.193 [localhost-startStop-16] INFO osc.c.c.ConfigServicePropertySourceLocator - Fetching config from server at: http://localhost:8888
17:35:54.292 [localhost-startStop-16] INFO osc.c.c.ConfigServicePropertySourceLocator - Connect Timeout Exception on Url - http://localhost:8888 . 如果可用,将尝试下一个 url
17:35:54.293 [localhost-startStop-16] WARN osc.c.c.ConfigServicePropertySourceLocator - Could not locate PropertySource: I/O error on GET request for " http://localhost:8888/application/default ": Connection refused ; 嵌套异常是 java.net.ConnectException: Connection denied 1
我在另一个线程上读到我需要对 pom 有 spring-cloud-starter-config 依赖,但我可以保证我有它。
这是我正在使用的 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>
提前谢谢了
请检查 bootstrap.yml 是否从 gradle 构建的 jar/war 中排除
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.