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

Spring引导执行器未工作和应用。STS中的属性未知

吕自明
2023-03-14

我希望在Spring Boot Actures:Production-ready features中根据文档在日志中映射

我尝试了Application.properties中的各种属性:

management.security.enabled=false 

management.endpoints.web.exposure.include=*

management.endpoints.web.expose=*

在STS中,所有三行都是黄色下划线,带有表示未知属性的消息。

<?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>

<groupId>com.geodepe.test</groupId>
<artifactId>health1</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>

<name>health1</name>
<description>Demo project for Spring Boot</description>

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.0.4.RELEASE</version>
    <relativePath/> <!-- lookup parent from repository -->
</parent>

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <java.version>1.8</java.version>
</properties>

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-actuator</artifactId>
    </dependency>
    <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>
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
    </plugins>
</build>
2018-08-06 21:06:14.235  INFO 52763 --- [ost-startStop-1] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 689 ms
2018-08-06 21:06:14.276  INFO 52763 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean  : Servlet dispatcherServlet mapped to [/]
2018-08-06 21:06:14.279  INFO 52763 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'characterEncodingFilter' to: [/*]
2018-08-06 21:06:14.279  INFO 52763 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2018-08-06 21:06:14.280  INFO 52763 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2018-08-06 21:06:14.280  INFO 52763 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'requestContextFilter' to: [/*]
2018-08-06 21:06:14.355  INFO 52763 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-08-06 21:06:14.484  INFO 52763 --- [           main] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for @ControllerAdvice: org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@a4102b8: startup date [Mon Aug 06 21:06:13 CDT 2018]; root of context hierarchy
2018-08-06 21:06:14.517  INFO 52763 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error]}" onto public org.springframework.http.ResponseEntity<java.util.Map<java.lang.String, java.lang.Object>> org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController.error(javax.servlet.http.HttpServletRequest)
2018-08-06 21:06:14.517  INFO 52763 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error],produces=[text/html]}" onto public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
2018-08-06 21:06:14.532  INFO 52763 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-08-06 21:06:14.532  INFO 52763 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-08-06 21:06:14.618  INFO 52763 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Registering beans for JMX exposure on startup
2018-08-06 21:06:14.653  INFO 52763 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8080 (http) with context path ''
2018-08-06 21:06:14.656  INFO 52763 --- [           main] c.f.test.health1.Health1Application      : Started Health1Application in 1.347 seconds (JVM running for 1.741)
curl 'http://localhost:8080/actuator/health' -i -X GET
HTTP/1.1 404 
Content-Type: application/json;charset=UTF-8
Transfer-Encoding: chunked
Date: Tue, 07 Aug 2018 03:09:02 GMT

{"timestamp":"2018-08-07T03:09:02.385+0000","status":404,"error":"Not Found","message":"No message available","path":"/actuator/health"}

有没有人能告诉我,我缺少了什么,为什么STS不能识别这些属性?

这不是“Acturet/Refresh is not being provideed in SpringBoot 2.0.1”的重复。下面的解决方案表明这是一个罐子损坏问题。

共有1个答案

钱华晖
2023-03-14

运行后

mvn clean install 

我看到了多个错误,即使IDE一直在运行而没有告诉我它们(奇怪)。

 [INFO] BUILD FAILURE
 [INFO] ------------------------------------------------------------------------
 [INFO] Total time: 1.774 s
 [INFO] Finished at: 2018-08-07T17:13:29-05:00
 [INFO] ------------------------------------------------------------------------
 [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.7.0:compile (default-compile) on project health1: Compilation failure: Compilation failure: 
 [ERROR] error reading /Users/xxx/.m2/repository/org/springframework/boot/spring-boot-actuator-autoconfigure/2.0.4.RELEASE/spring-boot-actuator-autoconfigure-2.0.4.RELEASE.jar; ZipFile invalid LOC header (bad signature)
 [ERROR] error reading /Users/xxx/.m2/repository/org/springframework/boot/spring-boot-actuator/2.0.4.RELEASE/spring-boot-actuator-2.0.4.RELEASE.jar; ZipFile invalid LOC header (bad signature)
 [ERROR] error reading /Users/xxx/.m2/repository/io/micrometer/micrometer-core/1.0.6/micrometer-core-1.0.6.jar; ZipFile invalid LOC header (bad signature)
 [ERROR] /Users/georgedeprez/Documents/workspace-sts/health1/src/main/java/com/finantica/test/health1/Health1Application.java:[1,1] cannot access com.finantica.test.health1
 [ERROR]   invalid code lengths set
 [ERROR] -> [Help 1]
 org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal    org.apache.maven.plugins:maven-compiler-plugin:3.7.0:compile (default-compile) on project health1: Compilation failure

删除JAR后:

rm /Users/xxx/.m2/repository/org/springframework/boot/spring-boot-actuator-autoconfigure/2.0.4.RELEASE/spring-boot-actuator-autoconfigure-2.0.4.RELEASE.jar
rm /Users/xxx/.m2/repository/org/springframework/boot/spring-boot-actuator/2.0.4.RELEASE/spring-boot-actuator-2.0.4.RELEASE.jar
rm /Users/xxx/.m2/repository/io/micrometer/micrometer-core/1.0.6/micrometer-core-1.0.6.jar
mvn spring-boot:run

强制重新下载

现在我看到了指示公开endpoint的日志:

/acture/health现在产生:

 类似资料:
  • 控制台输出: 我试图访问http://localhost:8080/acturet/health的执行器健康endpoint,但没有成功。

  • 我添加了执行器依赖 按照教程中的建议 但是当我点击时,它不会给出预期的结果。上面写着 Spring Boot版本为1.5.4。和Java1.8需要做哪些附加设置?

  • 执行器功能是通过在项目中添加“Spring-启动-启动-执行器”来提供的。 此时,security被禁用,因此项目不会导入Spring-Security。 使用spring-boot 1.5.x,所有执行器endpoint(自动提供,作为/info,以及我特定定义的endpoint)都正常工作。 使用spring-boot 1.5.x时,tomcat.version=9.0.0.m9 使用spri

  • 我的应用程序正在尝试外部化所有项目属性,一些属性将位于我的应用程序中,而另一个属性将位于 Windows 中某处的文件夹中。 我将Spring设置为这样执行:-Spring . config . location = file:///C:\ Temp \ config \ application . properties,class path:application . properties 如您

  • null 这是我的应用程序。属性: 当我发出此http请求时: 它回报我: