spring boot应用启动及关闭方式
一、spring boot启动方式1、在IDE中启动spring boot应用项目的启动 类Appplication.java的main方法;比如:@SpringBootApplicationpublic class EurekaClientApplication { public static void main(String[] args) { new SpringApplicatio
·
一、spring boot启动方式
1、在IDE中启动spring boot应用项目的启动 类Appplication.java的main方法;
比如:@SpringBootApplicationpublic class EurekaClientApplication { public static void main(String[] args) { new SpringApplicationBuilder(EurekaClientApplication.class).web(true).run(args); }}
2、在spring boot应用的根目录下使用maven命令执行(maven项目):mvn spring-boot:run
3、使用启动jar的方式,步骤如下:
A、进入spring boot应用根目录;
B、输入命令:mvn install -Dmaven.test.skip=true
C、cd target
D、java -jar ****.jar
二、spring boot应用关闭操作(Linux/unix/ubuntu环境下进行)
A、非安全验证
1、项目pom.xml添加如下依赖包:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
2、application.properties文件添加如下内容:
#启用shutdownendpoints.shutdown.enabled=true#禁用密码验证endpoints.shutdown.sensitive=false
3、关闭命令:
curl -X POST host:port/shutdown
B、安全验证
1、pom.xml添加如下依赖包:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
2、application.properties文件添加以下内容:
#开启shutdown的安全验证endpoints.shutdown.sensitive=true#验证用户名security.user.name=admin#验证密码security.user.password=admin#角色management.security.role=SUPERUSER# 指定端口management.port=8081# 指定地址management.address=127.0.0.1
3、关闭命令:
curl -u admin:admin -X POST http://127.0.0.1:8081/manage/shutdown
更多推荐
已为社区贡献1条内容
所有评论(0)