Я использую весеннюю загрузку 2.1.4.RELEASE и в настоящее время пытаюсь получить доступ к http://локальный:8080/привод, но получаю 404 не найден. Я не уверен, что я делаю неправильно здесь. Ниже приведены мои зависимости 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>
<groupId>com.dir</groupId>
<artifactId>api</artifactId>
<version>2.4.0</version>
<packaging>jar</packaging>
<name>Search</name>
<description>Search</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.4.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<distributionManagement>
<repository>
<id>Releases</id>
<name>repo1.releases</name>
<url>http://www.something.com</url>
</repository>
<snapshotRepository>
<id>Snapshots</id>
<name>repo1.com</name>
<url>http://repo1.com/artifactory/Snapshots</url>
</snapshotRepository>
</distributionManagement>
<properties>
<!--These two should be in all ParentPOMs -->
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<!-- Keep this version in sync with the pom's version ignoring "-SNAPSHOT" -->
<applicationVersion>1.0.0</applicationVersion>
<elasticsearch.version>5.2.0</elasticsearch.version>
<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-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.4.0</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.4.0</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webflux</artifactId>
</dependency>
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-annotations</artifactId>
<version>1.5.7</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.0</version>
</dependency>
<dependency>
<groupId>org.elasticsearch.client</groupId>
<artifactId>x-pack-transport</artifactId>
<version>5.2.1</version>
</dependency>
<dependency>
<groupId>org.elasticsearch.client</groupId>
<artifactId>transport</artifactId>
<version>5.2.0</version>
</dependency>
<dependency>
<groupId>org.elasticsearch</groupId>
<artifactId>elasticsearch</artifactId>
<version>5.2.0</version>
</dependency>
<dependency>
<groupId>apache-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.1</version>
</dependency>
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt</artifactId>
<version>0.7.0</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
<!-- Spring boot actuator to expose metrics endpoint -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<!-- Micormeter core dependecy -->
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-core</artifactId>
</dependency>
<!-- Micrometer Prometheus registry -->
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-registry-prometheus</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<environmentVariables>
<version>9.9.9</version>
<basePath>http://sample-basepath.com</basePath>
</environmentVariables>
</configuration>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/resources</directory>
</resource>
</resources>
</build>
</project>
конфиг файла свойств
management.endpoint.metrics.enabled=true
management.endpoints.web.exposure.include=*
management.endpoint.prometheus.enabled=true
management.metrics.export.prometheus.enabled=true
management.endpoint.health.show-details=always
management.endpoint.beans.enabled=true
когда я запускаю приложение, я вижу это в консоли
2019-04-27 00:04:25.406 INFO 32522 --- [ main] o.s.b.a.e.web.EndpointLinksResolver : Exposing 16 endpoint(s) beneath base path '/actuator'
2019-04-27 00:04:25.534 INFO 32522 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path '/myendpoint'
Я думаю, что в вашем приложении есть контекстный путь /myendpoint.
Пожалуйста, попробуйте с этой конечной точкой http://localhost:8080/myendpoint/actuator
Я попробовал это, и теперь я получаю 401 несанкционированный доступ.
Вы можете поделиться полным файлом pem.xml @JonAbraham
@RAJKUMAR я разместил полный файл POM.xml для вашего обзора
Я вижу, где проблема в консоли после того, как я добавил зависимость привода, я не вижу журналы такого типа -sbaewsWebMvcEndpointHandlerMapping : Mapped "{[/actuator/auditevents],methods=[GET],products=[application/ vnd.spring-boot.actuator.v2+json || application/json]}" на общедоступный java.lang.Object
Просто обновление, на котором я смог увидеть ответ - локальный хост: 8080/привод. Я просто удалил банку привода и сделал чистую установку maven. После этого я смог увидеть ответ
Пожалуйста, проверьте, настроили ли вы server.servlet.contextPath=/myendpoint
Если вы сделали это, попробуйте localhost:8080/{server.servlet.contextPath}/actuator
да, я настроил server.servlet.context-path=/myendpoint, но когда я попытался получить доступ - localhost:8080/myendpoint/actuator через браузер или почтальон, я получаю 401 неавторизованный вместо 404 не найден.
Мое приложение использует application.yml вместо application.properties, и я нашел настройку пути контекста как server: context-path: /some/path
Изменение URL-адреса Spring Boot Actuator в выпусках SpringBoot, Первоначально мы можем получить доступ к URL-адресу привода с помощью https://локальный:8080/привод.
в ранних версиях springboot 2.0.0 URL-адрес https://локальный:8080/приложение
Теперь текущая версия Springboot доступна через https://локальный:8080/привод
я попытался получить доступ к локальный хост: 8080/привод вместо локальный хост: 8080/привод, и теперь я вижу java.lang.IllegalArgumentException: в имени метода найден недопустимый символ. Имена методов HTTP должны быть токенами. Я полагаю, что это происходит, поскольку конечная точка моего клиента не настроена на https.
Уважаемый @JonAbraham, вы упомянули оба как localhost:8080/actuator, в чем разница?
Согласно приведенным выше ответам Попробуйте
http://localhost:8080/<server.servlet.context-path>/actuator/
но если он покажет ошибку, возможно, причина в том, что вы не включаете зависимость в свой pom.xml
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-actuator</artifactId> </dependency>
Если вы получаете 401 неавторизованный доступ, вам следует добавить в свой токен roll «ACTUATOR», тогда только вы сможете поразить конечные точки /actuator вашего приложения.
У меня была такая же ошибка 404, даже после точного следования документации Spring. Что, наконец, сработало для меня, так это удаление зависимости привода и банки и добавление ее снова с помощью чистой установки mvn. Это сработало :)
Некоторые конечные точки привода отключены, и их необходимо включить, прежде чем вы сможете их использовать. Я пытался получить доступ к /actuator/beans, который оказался именно такой конечной точкой. Согласно документы, все, что вам нужно, это включить их в свой файл application.properties:
management.endpoints.web.exposure.include=health,info,beans
у него уже есть эта строчка в свойствах: management.endpoints.web.exposure.include=*
Для меня это был конфликт версий, поэтому конечные точки привода не были раскрыты. Я удалил версию из файла pom для spring-boot-starter-actuator, чтобы она работала.
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
<!--<version>1.5.6.RELEASE</version>-->
</dependency>
Это был первый результат, когда я погуглил похожую проблему, которая у меня была. К сожалению, ни одно из приведенных выше решений не сработало для меня, но другой источник упомянул, что мне нужно установить порт управления:
management.server.port=8080
Что позволяет мне ударить
http://localhost:8080/actuator/
Также учтите management.endpoints.web.base-path=/manage
Для моего проекта проблема может быть решена путем добавления плагина maven-clean-plugin. В проекте я использую плагин spring-boot-maven следующим образом:
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<outputDirectory>./out</outputDirectory>
</configuration>
Я не смог просмотреть ни одного индикатора, пока не использовал maven-clean-plugin:
<artifactId>maven-clean-plugin</artifactId>
<configuration>
<filesets>
<fileset>
<directory>./out</directory>
</fileset>
</filesets>
</configuration>
У меня была аналогичная проблема, но моя проблема заключалась в том, что в моем проекте было установлено следующее свойство приложения:
management:
endpoints:
web:
base-path: /
Это означало, что фактическая конечная точка для чего-то вроде: http://localhost:8080/actuator/beans
было на самом деле: http://локальный:8080/бины
Я использую весенний ботинок. Я получил это простое сообщение от весенней загрузки.
Spring Boot /actuator returns 404 not found
вот мой файл application.yml.
server:
port: 6150
servlet:
context-path: /
management:
server:
port: 6150
endpoints:
web:
base-path: /actuator
exposure:
include: "*"
а потом:
http://localhost:6150/actuator
Я знаю, что этот вопрос устарел, и некоторые ситуации (условия) отличаются. Я надеюсь, что кто-то сэкономит свое время.
Пробовали
http://localhost:8080/myendpoint/actuator?