Commit 8fec6aaa by dengshichuan

Merge branch 'dsc' into 'develop'

Spring Boot actuator监控

See merge request 8timerv2/8timerapiv200!31
parents ae9745bb b9de4438
...@@ -11,9 +11,9 @@ ...@@ -11,9 +11,9 @@
</parent> </parent>
<groupId>cn.8timer</groupId> <groupId>cn.8timer</groupId>
<artifactId>8timerV200</artifactId> <artifactId>8timerV200</artifactId>
<version>0.0.1-SNAPSHOT</version> <version>v0.4-beta</version>
<name>8timerV200</name> <name>8timerV200</name>
<description>Demo project for Spring Boot</description> <description>8小时人事管家2.0</description>
<profiles> <profiles>
<profile> <profile>
...@@ -78,6 +78,16 @@ ...@@ -78,6 +78,16 @@
<artifactId>spring-boot-starter-test</artifactId> <artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<!-- <dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-security</artifactId>
</dependency> -->
<!-- 添加MySQL依赖 --> <!-- 添加MySQL依赖 -->
<dependency> <dependency>
...@@ -309,16 +319,16 @@ ...@@ -309,16 +319,16 @@
</dependency> </dependency>
<!--springboot-quartz --> <!--springboot-quartz -->
<dependency> <!-- <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-quartz</artifactId> <artifactId>spring-boot-starter-quartz</artifactId>
</dependency> </dependency> -->
<!--Quartz 使用的连接池 这里Quartz在持久化任务时使用该jar --> <!--Quartz 使用的连接池 这里Quartz在持久化任务时使用该jar -->
<dependency> <!-- <dependency>
<groupId>com.mchange</groupId> <groupId>com.mchange</groupId>
<artifactId>c3p0</artifactId> <artifactId>c3p0</artifactId>
<version>0.9.5.2</version> <version>0.9.5.2</version>
</dependency> </dependency> -->
<!-- pdf --> <!-- pdf -->
......
...@@ -35,6 +35,7 @@ public class WebSecurityConfig implements WebMvcConfigurer { ...@@ -35,6 +35,7 @@ public class WebSecurityConfig implements WebMvcConfigurer {
//.excludePathPatterns("/") //.excludePathPatterns("/")
registry.addInterceptor(getSessionInterceptor()) registry.addInterceptor(getSessionInterceptor())
.addPathPatterns("/**") .addPathPatterns("/**")
.excludePathPatterns("/actuator/*")
.excludePathPatterns("/doc*") .excludePathPatterns("/doc*")
.excludePathPatterns("/v2/**") .excludePathPatterns("/v2/**")
.excludePathPatterns("/**/*.js") .excludePathPatterns("/**/*.js")
......
package cn.timer.api.config.quartz; package cn.timer.api.config.quartz;
import org.quartz.Job; //import org.quartz.Job;
import org.quartz.JobExecutionContext; //import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException; //import org.quartz.JobExecutionException;
//
public interface BaseJob extends Job { //public interface BaseJob extends Job {
public void execute(JobExecutionContext context) throws JobExecutionException; // public void execute(JobExecutionContext context) throws JobExecutionException;
} //}
...@@ -10,7 +10,6 @@ import javax.servlet.http.HttpSession; ...@@ -10,7 +10,6 @@ import javax.servlet.http.HttpSession;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.env.Environment;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.interceptor.TransactionAspectSupport; import org.springframework.transaction.interceptor.TransactionAspectSupport;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
...@@ -53,9 +52,6 @@ import io.swagger.annotations.ApiOperation; ...@@ -53,9 +52,6 @@ import io.swagger.annotations.ApiOperation;
@Transactional @Transactional
@RequestMapping(value = "/login", produces = { "application/json" }) @RequestMapping(value = "/login", produces = { "application/json" })
public class LoginController { public class LoginController {
@Autowired
private Environment env;
@Value("${configtest.patht}") @Value("${configtest.patht}")
public String port; public String port;
......
...@@ -45,6 +45,7 @@ import cn.timer.api.controller.dzht.cn.tign.hz.constant.ConfigConstant; ...@@ -45,6 +45,7 @@ import cn.timer.api.controller.dzht.cn.tign.hz.constant.ConfigConstant;
import cn.timer.api.controller.dzht.cn.tign.hz.enums.RequestType; import cn.timer.api.controller.dzht.cn.tign.hz.enums.RequestType;
import cn.timer.api.controller.dzht.cn.tign.hz.exception.DefineException; import cn.timer.api.controller.dzht.cn.tign.hz.exception.DefineException;
import cn.timer.api.dto.dzht.DzhtRzDto; import cn.timer.api.dto.dzht.DzhtRzDto;
import cn.timer.api.utils.QueryUtil;
import cn.timer.api.utils.Result; import cn.timer.api.utils.Result;
import cn.timer.api.utils.ResultUtil; import cn.timer.api.utils.ResultUtil;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
...@@ -233,7 +234,20 @@ public class DzhtController { ...@@ -233,7 +234,20 @@ public class DzhtController {
return ResultUtil.data(list); return ResultUtil.data(list);
} }
final static String savePath = "esignTemplate";// 本地服务器文件保存路径
public static String savePath() {
String savePath = null;
String name = System.getProperty("os.name");
if (name.startsWith("Windows")) {
savePath = "E:\\esignTemplate"; // Windows本地服务器文件保存路径包
}else if(name.startsWith("Linux")){
savePath = "esignTemplate"; // Linux远程服务器文件保存路径包
}else {
savePath = "esignTemplate"; // 其他服务器文件保存路径包
}
return savePath;
}
final static String APP_ID = ConfigConstant.PROJECT_ID;// 项目id final static String APP_ID = ConfigConstant.PROJECT_ID;// 项目id
final static String APP_SECRET = ConfigConstant.PROJECT_SECRET;// 项目密码 final static String APP_SECRET = ConfigConstant.PROJECT_SECRET;// 项目密码
// final static String RE_TOKEN = "8b58973c290cc848b67ff0017cd424ff"; // final static String RE_TOKEN = "8b58973c290cc848b67ff0017cd424ff";
...@@ -595,7 +609,7 @@ public class DzhtController { ...@@ -595,7 +609,7 @@ public class DzhtController {
String filePath = null; String filePath = null;
try { try {
filePath = FileHelper.downLoadFromUrl(ossUrl, fileName, savePath); filePath = FileHelper.downLoadFromUrl(ossUrl, fileName, savePath());
} catch (IOException e1) { } catch (IOException e1) {
e1.printStackTrace(); e1.printStackTrace();
} }
...@@ -678,18 +692,11 @@ public class DzhtController { ...@@ -678,18 +692,11 @@ public class DzhtController {
} }
@GetMapping("/queryName") @GetMapping("/queryName")
@ApiOperation(value = "查版本名字", httpMethod = "GET", notes = "接口发布说明") @ApiOperation(value = "查名字", httpMethod = "GET", notes = "接口发布说明")
public Result<Object> getName(@RequestParam String empNum) { public Result<Object> getName(@RequestParam(required = false)Integer empNum) {
String a = System.getProperty("os.name"); String name = QueryUtil.queryEmpName(empNum);
String b = System.getProperty("os.arch"); Map<String, String> map = QueryUtil.queryVersionName();
String c = System.getProperty("os.version"); return ResultUtil.datas(map, name, "查询成功");
Map<String, String> map = new HashMap<>();
map.put("os.name", a);
map.put("os.arch", b);
map.put("os.version", c);
return ResultUtil.data(map);
// return ResultUtil.data(YgglMainEmp.builder().build()
// .selectOne(new QueryWrapper<YgglMainEmp>().eq("emp_num", empNum)).getName());
} }
/*************************** 设置请求头 ***************************************/ /*************************** 设置请求头 ***************************************/
......
...@@ -724,7 +724,7 @@ public class DzhtController2 { ...@@ -724,7 +724,7 @@ public class DzhtController2 {
String filePath = null; String filePath = null;
try { try {
filePath = FileHelper.downLoadFromUrl(ossUrl, fileName, DzhtController.savePath); filePath = FileHelper.downLoadFromUrl(ossUrl, fileName, DzhtController.savePath());
tpyz.setFilePath(filePath); tpyz.setFilePath(filePath);
} catch (IOException e1) { } catch (IOException e1) {
e1.printStackTrace(); e1.printStackTrace();
......
package cn.timer.api.utils;
import java.util.HashMap;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import cn.timer.api.bean.yggl.YgglMainEmp;
public class QueryUtil {
/**
* 查询当前系统名字与版本号
* @return
*/
public static Map<String, String> queryVersionName() {
String a = System.getProperty("os.name");
String b = System.getProperty("os.arch");
String c = System.getProperty("os.version");
Map<String, String> map = new HashMap<>();
map.put("os.name", a);
map.put("os.arch", b);
map.put("os.version", c);
return map;
}
/**
* 查询员工姓名
* @param empNum
* @return
*/
public static String queryEmpName(Integer empNum) {
return YgglMainEmp.builder().build()
.selectOne(new QueryWrapper<YgglMainEmp>().eq("emp_num", empNum)).getName();
}
}
...@@ -85,6 +85,26 @@ spring: ...@@ -85,6 +85,26 @@ spring:
height: 76 # Height of the banner image in chars (default based on image height). height: 76 # Height of the banner image in chars (default based on image height).
margin: 2 # Left hand image margin in chars. margin: 2 # Left hand image margin in chars.
invert: false # Whether images should be inverted for dark terminal themes. invert: false # Whether images should be inverted for dark terminal themes.
######### Spring boot应用健康监控
management:
endpoints:
web:
exposure:
include: "*" # 开启暴露所有的endpoint
endpoint:
health:
show-details: always # 显示健康具体信息 默认不会显示详细信息
# INFO ENDPOINT CONFIGURATION
info:
app:
name: '@project.name@'
description: '@project.description@'
version: '@project.version@'
encoding: '@project.build.sourceEncoding@'
java:
version: '@java.version@'
##############################
# mybatis-plus # mybatis-plus
mybatis-plus: mybatis-plus:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment