J'utilise Spring Boot 2.1.4.RELEASE
et j'essaie actuellement d'accéder à http: / / localhost: 8080 / actuator mais j'obtiens 404 introuvable. Je ne sais pas ce que je fais de mal ici. Voici mes dépendances pom -
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'
configuration du fichier de propriétés
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
quand j'exécute l'application, je vois cela dans la console
<?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>
4 Réponses :
Je pense qu'il existe un chemin de contexte / myendpoint dans votre application.
Veuillez essayer avec ce point de terminaison http: // localhost: 8080 / myendpoint / actuator
J'ai essayé ceci et maintenant je reçois 401 non autorisés.
pouvez-vous partager le fichier pem.xml complet @ JonAbraham
@RAJKUMAR J'ai publié le fichier POM.xml complet pour votre examen
Je vois où se trouve le problème dans la console après avoir ajouté la dépendance de l'actionneur, je ne vois pas ce type de journaux -sbaewsWebMvcEndpointHandlerMapping: Mapped "{[/ actuator / auditevents], methods = [GET], produit = [applicatio n / vnd.spring-boot.ac tuator.v2 + json || application / json]} "sur public java.lang.Object
Juste une mise à jour, j'ai pu voir la réponse sur - localhost: 8080 / actuator . J'ai simplement supprimé le bocal de l'actionneur et effectué une installation propre. Après cela, j'ai pu voir la réponse
Veuillez vérifier si vous avez configuré server.servlet.contextPath=/myendpoint
Si vous avez fait comme ça, veuillez essayer localhost: 8080 / {server.servlet.contextPath} / actuator
oui, j'ai configuré server.servlet.context-path = / myendpoint mais quand j'ai essayé d'accéder - localhost: 8080 / myendpoint / actuator via un navigateur ou un facteur, j'obtiens 401 non autorisés au lieu de 404 non trouvés.
Mon application utilise application.yml au lieu de application.properties et j'ai trouvé le paramètre de chemin de contexte en tant que serveur: chemin-contexte: / some / chemin
Modification de l'URL de l'actionneur Spring Boot via les versions SpringBoot, Au départ, nous pouvons accéder à l'URL de l'actionneur avec https: // localhost: 8080 / actuator
dans les premières versions jalons de springboot 2.0.0, l'URL est https: // localhost: 8080 / application < / p>
La version actuelle de springboot est désormais accessible via https: // localhost: 8080 / actuator
j'ai essayé d'accéder à localhost: 8080 / actuator au lieu de localhost: 8080 / actuator et maintenant je vois java.lang.IllegalArgumentException: Caractère non valide trouvé dans le nom de la méthode. Les noms de méthode HTTP doivent être des jetons. Je crois que cela se produit car mon point de terminaison client n'est pas configuré en https.
Cher @JonAbraham Vous avez mentionné les deux comme localhost: 8080 / actuator quelle est la différence?
Comme pour les réponses ci-dessus Essayez
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-actuator</artifactId> </dependency>
mais s'il affiche une erreur, il y aurait une raison possible est que vous n'incluez pas de dépendance dans votre pom.xml
http://localhost:8080/<server.servlet.context-path>/actuator/
Avez-vous essayé
http: // localhost: 8080 / myendpoint / actuator
?