spring-boot-starter-actuator不生效問題


 

引入依賴後spring-boot-starter-actuator,啓動應用並沒有出現對應的接口映射。以下問題的解決可能只跟我自己軟件和機器環境有關,僅供參考作用,不一定能幫助你直接解決你的問題。

我自己的pom文件設置如下。

<?xml version="1.0" encoding="UTF-8"?>
<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">
	<modelVersion>4.0.0</modelVersion>
	<parent>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter-parent</artifactId>
		<version>1.5.21.RELEASE</version>
		<relativePath/> <!-- lookup parent from repository -->
	</parent>
	<groupId>com.example</groupId>
	<artifactId>demo</artifactId>
	<version>0.0.1-SNAPSHOT</version>
	<name>demo</name>
	<description>Demo project for Spring Boot</description>

	<properties>
		<java.version>1.8</java.version>
	</properties>

	<dependencies>

		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-web</artifactId>
		</dependency>

		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-test</artifactId>
			<scope>test</scope>
		</dependency>


		<!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-actuator -->
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-actuator</artifactId>
		</dependency>

	</dependencies>

	<build>
		<plugins>
			<plugin>
				<groupId>org.springframework.boot</groupId>
				<artifactId>spring-boot-maven-plugin</artifactId>
			</plugin>
		</plugins>
	</build>

</project>

 

1.一開始覺得是引入問題,重新點擊了 reimport all maven project,發現pom文件還是沒有相關包的依賴。

 

2、正常來說打開pom文件顯示的是demo,但是出現問題的時候這裏的名稱是顯示Unknown

 

 

3、嘗試重啓idea並無卵用,最後的解決辦法是,我特地改動了spring-boot-starter-actuator的版本,並重新 reimport all maven project。然後是成功引入了spring-boot-starter-actuator jar包,unknown也重新變回了demo,再把指定版本移除,重新啓動應用spring-boot-starter-actuator又能正常工作了。其實關於idea經常有這種問題,要麼就去手動刪除本地倉庫的依賴。

	<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-actuator</artifactId>
			<version>1.5.10.RELEASE</version>
	</dependency>

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章