spring boot 项目在服务器上无法运行_Springboot(三十三)管理服务器

2f8a598693834be1a938e763bf47c10e

使用Spring Boot Actuator Endpoint监控应用程序有点困难。 因为,如果有’n’个应用程序,每个应用程序都有单独的执行器端点,从而使监控变得困难。 Spring Boot Admin Server是一个用于管理和监控Microservice应用程序的程序。

要处理这种情况,CodeCentric Team提供了一个Spring Boot Admin UI,用于在一个地方管理和监控所有Spring Boot应用程序Actuator端点。

要构建Spring Boot Admin Server,需要在构建配置文件中添加以下依赖项。

Maven用户可以在pom.xml 文件中添加以下依赖项 -

de.codecentric spring-boot-admin-server 1.5.5de.codecentric spring-boot-admin-server-ui 1.5.5

Gradle用户可以在build.gradle 文件中添加以下依赖项 -

compile group: 'de.codecentric', name: 'spring-boot-admin-server', version: '1.5.5'compile group: 'de.codecentric', name: 'spring-boot-admin-server-ui', version: '1.5.5'

在主Spring Boot应用程序类文件中添加@EnableAdminServer注解。 @EnableAdminServer注解用于使管理服务器监视所有其他微服务。

package com.felix.adminserver;import org.springframework.boot.SpringApplication;import org.springframework.boot.autoconfigure.SpringBootApplication;import de.codecentric.boot.admin.config.EnableAdminServer;@SpringBootApplication@EnableAdminServerpublic class AdminserverApplication {  public static void main(String[] args) { SpringApplication.run(AdminserverApplication.class, args); }}

现在,在application.properties文件中定义server.port和application.name,如图所示 -

server.port = 9090spring.application.name = adminserver

对于YAML用户,请使用以下属性在application.yml 文件中定义端口号和应用程序名称。

server: port: 9090spring: application: name: adminserver

构建配置文件如下所示。

对于Maven用户,完整的构建文件 - pom.xml 内容如下:

<?xml version = "1.0" encoding = "UTF-8"?>4.0.0com.felix adminserver 0.0.1-SNAPSHOTjaradminserverDemo project for Spring Bootorg.springframework.boot spring-boot-starter-parent 1.5.9.RELEASEUTF-8UTF-81.8org.springframework.boot spring-boot-starter de.codecentric spring-boot-admin-server 1.5.5de.codecentric spring-boot-admin-server-ui 1.5.5org.springframework.boot spring-boot-starter-test testorg.springframework.boot spring-boot-maven-plugin 

对于Gradle用户,构建文件 - build.gradle 的内容如下:

buildscript { ext { springBootVersion = '1.5.9.RELEASE' } repositories { mavenCentral() } dependencies { classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}") }}apply plugin: 'java'apply plugin: 'eclipse'apply plugin: 'org.springframework.boot'group = 'com.felix'version = '0.0.1-SNAPSHOT'sourceCompatibility = 1.8repositories {  mavenCentral()}dependencies { compile('org.springframework.boot:spring-boot-starter') compile group: 'de.codecentric', name: 'spring-boot-admin-server', version: '1.5.5' compile group: 'de.codecentric', name: 'spring-boot-admin-server-ui', version: '1.5.5'  testCompile('org.springframework.boot:spring-boot-starter-test')}

可以创建可执行的JAR文件,并使用以下Maven或Gradle命令运行Spring Boot应用程序 -

对于Maven,请使用以下命令 -

mvn clean install

在“BUILD SUCCESS”之后,可以在target目录下找到JAR文件。

对于Gradle,请使用以下命令 -

gradle clean build

在“BUILD SUCCESSFUL” 之后,可以在build/libs目录下找到JAR文件。

现在,使用下面给出的命令运行JAR文件 -

java –jar 

现在,应用程序已在Tomcat端口9090上启动。

现在,在Web浏览器中访问以下URL => http://localhost:9090/,然后查看管理服务器UI。

731fe3e8cea3470c91ffcb46cf81c58f
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值