mirror of
https://gitee.com/wangkang/udf.git
synced 2026-10-24 23:03:40 +00:00
更新
This commit is contained in:
@@ -24,6 +24,7 @@
|
||||
<modules>
|
||||
<module>udf-eureka-config-server</module>
|
||||
<module>udf-admin-server</module>
|
||||
<module>udf-demo-server</module>
|
||||
</modules>
|
||||
<!-- 依赖管理 -->
|
||||
<dependencyManagement>
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
<?xml version="1.0"?>
|
||||
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
|
||||
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<!-- maven坐标 -->
|
||||
<artifactId>udf-demo-server</artifactId>
|
||||
<name>udf-demo-server</name>
|
||||
<packaging>jar</packaging>
|
||||
<url>http://itkk.org:81</url>
|
||||
<!-- 父依赖 -->
|
||||
<parent>
|
||||
<groupId>org.itkk.udf</groupId>
|
||||
<artifactId>udf-server</artifactId>
|
||||
<version>1.0</version>
|
||||
</parent>
|
||||
<!-- 参数 -->
|
||||
<properties>
|
||||
<server.port>9003</server.port>
|
||||
<management.port>8003</management.port>
|
||||
</properties>
|
||||
<!-- 依赖 -->
|
||||
<dependencies>
|
||||
<!-- udf-starter-core -->
|
||||
<dependency>
|
||||
<groupId>org.itkk.udf</groupId>
|
||||
<artifactId>udf-starter-core</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<!-- 构建 -->
|
||||
<build>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>${project.basedir}/src/main/resources/</directory>
|
||||
<filtering>true</filtering>
|
||||
</resource>
|
||||
</resources>
|
||||
<plugins>
|
||||
<!-- package -->
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<version>${springboot.version}</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>repackage</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
package org.itkk.udf.demo.server;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.cloud.client.SpringCloudApplication;
|
||||
|
||||
@SpringCloudApplication
|
||||
public class UdfDemoServerApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(UdfDemoServerApplication.class, args);
|
||||
}
|
||||
|
||||
}
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
package org.itkk.udf.demo.server.core;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
@RestControllerAdvice
|
||||
@Slf4j
|
||||
public class ExceptionControllerAdvice {
|
||||
|
||||
/**
|
||||
* 全局异常处理
|
||||
*
|
||||
* @param req 请求对象
|
||||
* @param e 异常对象
|
||||
* @return ResponseEntity
|
||||
*/
|
||||
@ExceptionHandler(Exception.class)
|
||||
public ResponseEntity<?> jsonErrorHandler(HttpServletRequest req, Exception e) {
|
||||
log.error("rest请求错误:", e);
|
||||
HttpStatus status = getStatus(req);
|
||||
return new ResponseEntity<>(e.getClass().getName(), status);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得错误响应状态
|
||||
*
|
||||
* @param request request
|
||||
* @return HttpStatus
|
||||
*/
|
||||
private HttpStatus getStatus(HttpServletRequest request) {
|
||||
Integer statusCode = (Integer) request.getAttribute("javax.servlet.error.status_code");
|
||||
if (statusCode == null) {
|
||||
return HttpStatus.INTERNAL_SERVER_ERROR;
|
||||
}
|
||||
return HttpStatus.valueOf(statusCode);
|
||||
}
|
||||
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
package org.itkk.udf.demo.server.domain;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
public class DemoEntity {
|
||||
private String name;
|
||||
private Date date;
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
package org.itkk.udf.demo.server.service;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
public class DemoService {
|
||||
public void t1() {
|
||||
log.info("这是日志");
|
||||
int a = 1 / 0;
|
||||
}
|
||||
}
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
package org.itkk.udf.demo.server.web;
|
||||
|
||||
import org.itkk.udf.demo.server.domain.DemoEntity;
|
||||
import org.itkk.udf.demo.server.service.DemoService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@RestController("demoController")
|
||||
@RequestMapping("demo")
|
||||
public class DemoController {
|
||||
|
||||
@Autowired
|
||||
private DemoService demoService;
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, path = "t1/{name}")
|
||||
public DemoEntity t1(@PathVariable String name) {
|
||||
demoService.t1();
|
||||
return new DemoEntity(name,new Date());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
.----------------. .----------------. .----------------.
|
||||
| .--------------. || .--------------. || .--------------. |
|
||||
| | _____ _____ | || | ________ | || | _________ | |
|
||||
| ||_ _||_ _|| || | |_ ___ `. | || | |_ ___ | | |
|
||||
| | | | | | | || | | | `. \ | || | | |_ \_| | |
|
||||
| | | ' ' | | || | | | | | | || | | _| | |
|
||||
| | \ `--' / | || | _| |___.' / | || | _| |_ | |
|
||||
| | `.__.' | || | |________.' | || | |_____| | |
|
||||
| | | || | | || | | |
|
||||
| '--------------' || '--------------' || '--------------' |
|
||||
'----------------' '----------------' '----------------'
|
||||
@@ -0,0 +1,16 @@
|
||||
# EUREKA.ENVIRONMENT ( EurekaServerBootstrap )
|
||||
eureka.environment=${spring.profiles.active}
|
||||
# EUREKA.INSTANCE ( EurekaInstanceConfigBean )
|
||||
eureka.instance.preferIpAddress=true
|
||||
# EUREKA.CLIENT (EurekaClientConfigBean , EurekaServerConfigBean )
|
||||
eureka.client.serviceUrl.defaultZone=http://127.0.0.1:9001/eureka/
|
||||
# SPRING.CLOUD.CONFIG.SERVER.GIT ( MultipleJGitEnvironmentRepository ) ({application}/{profile}/{label})
|
||||
spring.cloud.config.enabled=true
|
||||
spring.cloud.config.profile=${spring.profiles.active}
|
||||
spring.cloud.config.name=test
|
||||
spring.cloud.config.label=2.X_and_Finchley.X
|
||||
spring.cloud.config.failFast=true
|
||||
spring.cloud.config.discovery.enabled=true
|
||||
spring.cloud.config.discovery.serviceId=UDF-EUREKA-CONFIG-SERVER
|
||||
# LOGGING
|
||||
logging.file=d:/develop/application-log/${spring.application.name}_${server.port}_${spring.profiles.active}/base.log
|
||||
@@ -0,0 +1,34 @@
|
||||
# INFO
|
||||
info.build.group=${project.groupId}
|
||||
info.build.artifact=${project.artifactId}
|
||||
info.build.version=${project.version}
|
||||
info.build.name=${spring.application.name}
|
||||
info.build.env=${spring.profiles.active}
|
||||
info.build.time=${project.build.date}
|
||||
info.build.encoding=${project.build.sourceEncoding}
|
||||
info.build.java.source=${java.version}
|
||||
info.build.java.target=${java.version}
|
||||
# SPRING
|
||||
spring.application.name=${project.name}
|
||||
# HTTP SERVER
|
||||
server.port=${server.port}
|
||||
# MANAGEMENT HTTP SERVER (ManagementServerProperties)
|
||||
#management.server.address=127.0.0.1
|
||||
management.server.port=${management.port}
|
||||
# ENDPOINTS WEB CONFIGURATION (WebEndpointProperties)
|
||||
management.endpoints.web.exposure.include=*
|
||||
# ENDPOINT
|
||||
management.endpoint.health.showDetails=always
|
||||
management.endpoint.shutdown.enabled=true
|
||||
management.endpoint.restart.enabled=true
|
||||
management.endpoint.pause.enabled=true
|
||||
management.endpoint.resume.enabled=true
|
||||
# JACKSON
|
||||
#spring.jackson.dateFormat=${org.itkk.application.config.dateFormat}
|
||||
#spring.jackson.jodaDateTimeFormat=${org.itkk.application.config.dateFormat}
|
||||
spring.jackson.timeZone=Asia/Shanghai
|
||||
spring.jackson.serialization.INDENT_OUTPUT=true
|
||||
spring.jackson.serialization.FAIL_ON_EMPTY_BEANS=true
|
||||
spring.jackson.deserialization.FAIL_ON_UNKNOWN_PROPERTIES=true
|
||||
spring.jackson.parser.ALLOW_SINGLE_QUOTES=true
|
||||
spring.jackson.parser.ALLOW_UNQUOTED_CONTROL_CHARS=true
|
||||
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration>
|
||||
<include resource="org/springframework/boot/logging/logback/base.xml" />
|
||||
<jmxConfigurator />
|
||||
</configuration>
|
||||
Reference in New Issue
Block a user