tomcat SpringBoot Web与SpringBoot Actuator冲突

olmpazwi  于 2024-01-08  发布在  Spring
关注(0)|答案(1)|浏览(286)

我最近更新了一个SpringBoot应用程序,从使用Spring Starter 2.1.0-RELEASE到2.7.14。
除了一些小的修改之外,我一直在努力解决一个依赖项spring-boot-starter-actuator,我需要它来公开应用程序的JMX端点(比如health),用于监视应用程序的状态和运行状况。
有2例:
1.如果我添加spring-boot-starter-actuator依赖项和spring-boot-starter-web,这将导致Tomcat服务器永远不会启动,Spring应用程序实际上会挂起,需要手动终止(kill-9)。
1.如果spring-boot-starter-actuator依赖项不是以下POM的一部分,则应用程序将正常运行,Tomcat Server将启动,一切都将顺利运行,但不会公开JMX端点,并且无法监视应用程序。
问:

Spring Start 2.7.14的pom.xml中同时包含spring-boot-starter-webspring-boot-starter-actuator是否存在任何冲突/已知问题?

下面说的pom.xml:

  1. <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  2. <modelVersion>4.0.0</modelVersion>
  3. <name>MyWebServer - Example</name>
  4. <groupId>org.jones.robert</groupId>
  5. <artifactId>wbs</artifactId>
  6. <version>1000-SNAPSHOT</version>
  7. <parent>
  8. <groupId>org.springframework.boot</groupId>
  9. <artifactId>spring-boot-starter-parent</artifactId>
  10. <version>2.7.14</version>
  11. </parent>
  12. <properties>
  13. <vertx.version>3.9.16</vertx.version>
  14. <activemq.version>5.18.2</activemq.version>
  15. <mockito.version>4.5.1</mockito.version>
  16. <slf4j.version>1.7.36</slf4j.version>
  17. <jackson.version>2.15.2</jackson.version>
  18. <spring-project.version>2.7.14</spring-project.version>
  19. </properties>
  20. <dependencies>
  21. <dependency>
  22. <groupId>io.vertx</groupId>
  23. <artifactId>vertx-core</artifactId>
  24. <version>${vertx.version}</version>
  25. </dependency>
  26. <dependency>
  27. <groupId>org.springframework.boot</groupId>
  28. <artifactId>spring-boot-starter-web</artifactId>
  29. <exclusions>
  30. <exclusion>
  31. <groupId>org.springframework.boot</groupId>
  32. <artifactId>spring-boot-starter-logging</artifactId>
  33. </exclusion>
  34. </exclusions>
  35. </dependency>
  36. <dependency>
  37. <groupId>org.springframework.boot</groupId>
  38. <artifactId>spring-boot-starter-security</artifactId>
  39. </dependency>
  40. <dependency>
  41. <groupId>org.springframework.security</groupId>
  42. <artifactId>spring-security-messaging</artifactId>
  43. </dependency>
  44. <dependency>
  45. <groupId>org.springframework.boot</groupId>
  46. <artifactId>spring-boot-starter-data-jpa</artifactId>
  47. </dependency>
  48. <dependency>
  49. <groupId>org.springframework.boot</groupId>
  50. <artifactId>spring-boot-starter-jdbc</artifactId>
  51. </dependency>
  52. <dependency>
  53. <groupId>org.springframework.boot</groupId>
  54. <artifactId>spring-boot-starter-websocket</artifactId>
  55. </dependency>
  56. <dependency>
  57. <groupId>org.springframework.boot</groupId>
  58. <artifactId>spring-boot-starter-log4j2</artifactId>
  59. <version>${spring-project.version}</version>
  60. </dependency>
  61. <dependency>
  62. <groupId>org.springframework.boot</groupId>
  63. <artifactId>spring-boot-starter-actuator</artifactId>
  64. <version>${spring-project.version}</version>
  65. </dependency>
  66. <dependency>
  67. <groupId>org.springframework.boot</groupId>
  68. <artifactId>spring-boot-starter-activemq</artifactId>
  69. </dependency>
  70. <dependency>
  71. <groupId>org.apache.activemq</groupId>
  72. <artifactId>activemq-pool</artifactId>
  73. <version>${activemq.version}</version>
  74. </dependency>
  75. <dependency>
  76. <groupId>org.postgresql</groupId>
  77. <artifactId>postgresql</artifactId>
  78. <version>42.6.0</version>
  79. </dependency>
  80. <dependency>
  81. <groupId>org.projectlombok</groupId>
  82. <artifactId>lombok</artifactId>
  83. <version>1.18.28</version>
  84. <scope>provided</scope>
  85. </dependency>
  86. <dependency>
  87. <groupId>com.fasterxml.jackson.core</groupId>
  88. <artifactId>jackson-core</artifactId>
  89. <version>${jackson.version}</version>
  90. </dependency>
  91. <dependency>
  92. <groupId>com.fasterxml.jackson.core</groupId>
  93. <artifactId>jackson-annotations</artifactId>
  94. <version>${jackson.version}</version>
  95. </dependency>
  96. <dependency>
  97. <groupId>com.fasterxml.jackson.core</groupId>
  98. <artifactId>jackson-databind</artifactId>
  99. <version>${jackson.version}</version>
  100. </dependency>
  101. <dependency>
  102. <groupId>org.apache.commons</groupId>
  103. <artifactId>commons-lang3</artifactId>
  104. <version>3.12.0</version>
  105. </dependency>
  106. <dependency>
  107. <groupId>commons-io</groupId>
  108. <artifactId>commons-io</artifactId>
  109. <version>2.11.0</version>
  110. </dependency>
  111. <dependency>
  112. <groupId>commons-validator</groupId>
  113. <artifactId>commons-validator</artifactId>
  114. <version>1.7</version>
  115. </dependency>
  116. <dependency>
  117. <groupId>javax.validation</groupId>
  118. <artifactId>validation-api</artifactId>
  119. <version>2.0.1.Final</version>
  120. </dependency>
  121. <dependency>
  122. <groupId>org.hibernate.validator</groupId>
  123. <artifactId>hibernate-validator</artifactId>
  124. <version>6.2.5.Final</version>
  125. </dependency>
  126. <!-- TESTING -->
  127. <dependency>
  128. <groupId>org.springframework.boot</groupId>
  129. <artifactId>spring-boot-starter-test</artifactId>
  130. <scope>test</scope>
  131. </dependency>
  132. <dependency>
  133. <groupId>org.mockito</groupId>
  134. <artifactId>mockito-core</artifactId>
  135. <version>${mockito.version}</version>
  136. <scope>test</scope>
  137. </dependency>
  138. <dependency>
  139. <groupId>junit</groupId>
  140. <artifactId>junit</artifactId>
  141. <version>4.13.2</version>
  142. <scope>test</scope>
  143. </dependency>
  144. <dependency>
  145. <groupId>com.h2database</groupId>
  146. <artifactId>h2</artifactId>
  147. <version>2.2.220</version>
  148. <scope>test</scope>
  149. </dependency>
  150. <dependency>
  151. <groupId>org.cache2k</groupId>
  152. <artifactId>cache2k-base-bom</artifactId>
  153. <version>1.6.0.Final</version>
  154. <type>pom</type>
  155. </dependency>
  156. <dependency>
  157. <groupId>com.google.guava</groupId>
  158. <artifactId>guava</artifactId>
  159. <version>32.1.1-jre</version>
  160. <exclusions>
  161. <exclusion>
  162. <groupId>org.checkerframework</groupId>
  163. <artifactId>checker-qual</artifactId>
  164. </exclusion>
  165. </exclusions>
  166. </dependency>
  167. </dependencies>
  168. <build>
  169. <plugins>
  170. <plugin>
  171. <groupId>org.springframework.boot</groupId>
  172. <artifactId>spring-boot-maven-plugin</artifactId>
  173. <version>${project.parent.version}</version>
  174. </plugin>
  175. <plugin>
  176. <artifactId>maven-compiler-plugin</artifactId>
  177. <version>3.7.0</version>
  178. <configuration>
  179. <source>11</source>
  180. <target>11</target>
  181. <forceJavacCompilerUse>true</forceJavacCompilerUse>
  182. </configuration>
  183. <dependencies>
  184. <dependency>
  185. <groupId>org.ow2.asm</groupId>
  186. <artifactId>asm</artifactId>
  187. <version>6.1</version> <!-- Use newer version of ASM -->
  188. </dependency>
  189. </dependencies>
  190. </plugin>
  191. <plugin>
  192. <groupId>org.apache.maven.plugins</groupId>
  193. <artifactId>maven-surefire-plugin</artifactId>
  194. <version>2.22.2</version>
  195. </plugin>
  196. <plugin>
  197. <groupId>com.github.spotbugs</groupId>
  198. <artifactId>spotbugs-maven-plugin</artifactId>
  199. <version>3.1.9</version>
  200. </plugin>
  201. <plugin>
  202. <groupId>org.apache.maven.plugins</groupId>
  203. <artifactId>maven-release-plugin</artifactId>
  204. <version>2.5.3</version>
  205. </plugin>
  206. <plugin>
  207. <groupId>org.apache.maven.plugins</groupId>
  208. <artifactId>maven-jar-plugin</artifactId>
  209. <configuration>
  210. <archive>
  211. <manifestEntries>
  212. <condor-version>${project.version}</condor-version>
  213. </manifestEntries>
  214. </archive>
  215. </configuration>
  216. </plugin>
  217. </plugins>
  218. </build>
  219. <profiles>
  220. <profile>
  221. <id>prod</id>
  222. <build>
  223. <plugins>
  224. <plugin>
  225. <groupId>org.apache.maven.plugins</groupId>
  226. <artifactId>maven-resources-plugin</artifactId>
  227. <executions>
  228. <execution>
  229. <id>copy-resources</id>
  230. <phase>validate</phase>
  231. <goals>
  232. <goal>copy-resources</goal>
  233. </goals>
  234. <configuration>
  235. <outputDirectory>${project.build.directory}/classes/public/</outputDirectory>
  236. <resources>
  237. <resource>
  238. <directory>${project.basedir}/../management-console-ui/dist/</directory>
  239. </resource>
  240. </resources>
  241. </configuration>
  242. </execution>
  243. </executions>
  244. </plugin>
  245. </plugins>
  246. </build>
  247. </profile>
  248. <profile>
  249. <activation>
  250. <activeByDefault>true</activeByDefault>
  251. </activation>
  252. <id>codeQuality</id>
  253. <build>
  254. <plugins>
  255. <plugin>
  256. <groupId>com.github.spotbugs</groupId>
  257. <artifactId>spotbugs-maven-plugin</artifactId>
  258. <configuration>
  259. <xmlOutput>true</xmlOutput>
  260. <trace>true</trace>
  261. </configuration>
  262. <executions>
  263. <execution>
  264. <phase>test</phase>
  265. <id>spotbugs</id>
  266. <goals>
  267. <goal>check</goal>
  268. </goals>
  269. </execution>
  270. </executions>
  271. </plugin>
  272. <plugin>
  273. <groupId>org.apache.maven.plugins</groupId>
  274. <artifactId>maven-shade-plugin</artifactId>
  275. <version>3.4.1</version>
  276. <executions>
  277. <execution>
  278. <phase>package</phase>
  279. <goals>
  280. <goal>shade</goal>
  281. </goals>
  282. </execution>
  283. </executions>
  284. </plugin>
  285. </plugins>
  286. </build>
  287. <reporting>
  288. <plugins>
  289. <plugin>
  290. <groupId>com.github.spotbugs</groupId>
  291. <artifactId>spotbugs-maven-plugin</artifactId>
  292. <configuration>
  293. <xmlOutput>true</xmlOutput>
  294. <trace>true</trace>
  295. </configuration>
  296. <reportSets>
  297. <reportSet>
  298. <reports>
  299. <report>spotbugs</report>
  300. </reports>
  301. </reportSet>
  302. </reportSets>
  303. </plugin>
  304. </plugins>
  305. </reporting>
  306. </profile>
  307. </profiles>
  308. </project>

字符串

brjng4g3

brjng4g31#

我从来没有真正找到这个问题的根本原因,但解决方案是使用spring-boot-actuator-autoconfigure而不是spring-boot-actuator
这避免了与spring-boot-starter-web的任何冲突,并允许公开JMX端点。

相关问题