parent
9b8f834d54
commit
2ed7494790
@ -0,0 +1,45 @@ |
||||
<?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"> |
||||
<parent> |
||||
<groupId>com.hai</groupId> |
||||
<artifactId>hai-parent</artifactId> |
||||
<version>1.0-SNAPSHOT</version> |
||||
</parent> |
||||
<modelVersion>4.0.0</modelVersion> |
||||
|
||||
<groupId>com.hgj</groupId> |
||||
<artifactId>hai-v1</artifactId> |
||||
|
||||
<dependencies> |
||||
<dependency> |
||||
<groupId>com.hai</groupId> |
||||
<artifactId>hai-service</artifactId> |
||||
<version>PACKT-SNAPSHOT</version> |
||||
</dependency> |
||||
</dependencies> |
||||
|
||||
<build> |
||||
<resources> |
||||
<resource> |
||||
<directory>src/main/resources/${env}</directory> |
||||
<filtering>false</filtering> |
||||
</resource> |
||||
</resources> |
||||
<plugins> |
||||
<plugin> |
||||
<groupId>org.apache.maven.plugins</groupId> |
||||
<artifactId>maven-surefire-plugin</artifactId> |
||||
<configuration> |
||||
<skip>true</skip> |
||||
</configuration> |
||||
</plugin> |
||||
<plugin> |
||||
<groupId>org.springframework.boot</groupId> |
||||
<artifactId>spring-boot-maven-plugin</artifactId> |
||||
</plugin> |
||||
</plugins> |
||||
</build> |
||||
|
||||
</project> |
@ -0,0 +1,28 @@ |
||||
package com; |
||||
|
||||
import com.hai.common.utils.SpringContextUtil; |
||||
import org.mybatis.spring.annotation.MapperScan; |
||||
import org.springframework.boot.SpringApplication; |
||||
import org.springframework.boot.autoconfigure.SpringBootApplication; |
||||
import org.springframework.boot.web.servlet.ServletComponentScan; |
||||
import org.springframework.context.ApplicationContext; |
||||
import org.springframework.context.annotation.EnableAspectJAutoProxy; |
||||
import org.springframework.scheduling.annotation.EnableScheduling; |
||||
import org.springframework.transaction.annotation.EnableTransactionManagement; |
||||
|
||||
@SpringBootApplication |
||||
// @ComponentScan
|
||||
@EnableTransactionManagement |
||||
@EnableScheduling |
||||
@ServletComponentScan |
||||
@EnableAspectJAutoProxy(proxyTargetClass = true) |
||||
@MapperScan("com.hai.dao") |
||||
public class V1Application |
||||
{ |
||||
public static void main( String[] args ) |
||||
{ |
||||
ApplicationContext app = SpringApplication.run(V1Application.class, args); |
||||
SpringContextUtil.setApplicationContext(app); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,128 @@ |
||||
package com.v1.config; |
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper; |
||||
import com.fasterxml.jackson.databind.module.SimpleModule; |
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; |
||||
import com.hai.common.security.UserCenter; |
||||
import org.apache.commons.lang3.StringUtils; |
||||
import org.slf4j.Logger; |
||||
import org.slf4j.LoggerFactory; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.beans.factory.annotation.Value; |
||||
import org.springframework.context.annotation.Configuration; |
||||
import org.springframework.http.converter.HttpMessageConverter; |
||||
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; |
||||
import org.springframework.web.multipart.support.StandardMultipartHttpServletRequest; |
||||
import org.springframework.web.servlet.config.annotation.InterceptorRegistry; |
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; |
||||
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter; |
||||
|
||||
import javax.servlet.http.HttpServletRequest; |
||||
import javax.servlet.http.HttpServletResponse; |
||||
import java.util.List; |
||||
|
||||
@Configuration |
||||
public class AuthConfig implements WebMvcConfigurer { |
||||
|
||||
private static Logger log = LoggerFactory.getLogger(AuthConfig.class); |
||||
|
||||
@Autowired |
||||
private UserCenter userCenter; |
||||
|
||||
/** |
||||
* 获取配置文件debug变量 |
||||
*/ |
||||
@Value("${debug}") |
||||
private boolean debug = false; |
||||
|
||||
/** |
||||
* 解决18位long类型数据转json失去精度问题 |
||||
* @param converters |
||||
*/ |
||||
@Override |
||||
public void configureMessageConverters(List<HttpMessageConverter<?>> converters){ |
||||
MappingJackson2HttpMessageConverter jsonConverter = new MappingJackson2HttpMessageConverter(); |
||||
|
||||
ObjectMapper objectMapper = jsonConverter.getObjectMapper(); |
||||
SimpleModule simpleModule = new SimpleModule(); |
||||
simpleModule.addSerializer(Long.class, ToStringSerializer.instance); |
||||
simpleModule.addSerializer(Long.TYPE, ToStringSerializer.instance); |
||||
objectMapper.registerModule(simpleModule); |
||||
|
||||
converters.add(jsonConverter); |
||||
} |
||||
|
||||
public void addInterceptors(InterceptorRegistry registry) { |
||||
registry.addInterceptor(new HandlerInterceptorAdapter() { |
||||
|
||||
@Override |
||||
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, |
||||
Object handler) throws Exception { |
||||
if(debug){ |
||||
return true; |
||||
} |
||||
String token = request.getParameter("Authorization"); |
||||
if (StringUtils.isBlank(token)) { |
||||
token = request.getHeader("Authorization"); |
||||
} |
||||
if((StringUtils.isNotBlank(token) && userCenter.isTokenLogin(token)) || userCenter.isLogin(request)){//如果未登录,将无法使用任何接口
|
||||
userCenter.refreshCookie(request, response); |
||||
return true; |
||||
} else if(request instanceof StandardMultipartHttpServletRequest) { |
||||
StandardMultipartHttpServletRequest re = (StandardMultipartHttpServletRequest)request; |
||||
if(userCenter.isLogin(re.getRequest())){ |
||||
return true; |
||||
} else { |
||||
log.error("the user is not logged in,remoteAddr:"+getIpAddress(request)+",requestUrl:"+request.getRequestURL()); |
||||
response.setStatus(401); |
||||
return false; |
||||
} |
||||
} else{ |
||||
log.error("the user is not logged in,remoteAddr:"+getIpAddress(request)+",requestUrl:"+request.getRequestURL()); |
||||
response.setStatus(401); |
||||
return false; |
||||
} |
||||
} |
||||
}) |
||||
.addPathPatterns("/**") |
||||
.excludePathPatterns("/swagger-resources/**") |
||||
.excludePathPatterns("/**/api-docs") |
||||
.excludePathPatterns("/**/springfox-swagger-ui/**") |
||||
.excludePathPatterns("/**/swagger-ui.html") |
||||
.excludePathPatterns("/websocket/*") |
||||
; |
||||
} |
||||
|
||||
public String getIpAddress(HttpServletRequest request) { |
||||
// 获取请求主机IP地址,如果通过代理进来,则透过防火墙获取真实IP地址
|
||||
String ip = request.getHeader("X-Forwarded-For"); |
||||
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { |
||||
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { |
||||
ip = request.getHeader("Proxy-Client-IP"); |
||||
} |
||||
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { |
||||
ip = request.getHeader("WL-Proxy-Client-IP"); |
||||
} |
||||
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { |
||||
ip = request.getHeader("HTTP_CLIENT_IP"); |
||||
} |
||||
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { |
||||
ip = request.getHeader("HTTP_X_FORWARDED_FOR"); |
||||
} |
||||
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { |
||||
ip = request.getRemoteAddr(); |
||||
} |
||||
} else if (ip.length() > 15) { |
||||
String[] ips = ip.split(","); |
||||
for (int index = 0; index < ips.length; index++) { |
||||
String strIp = ips[index]; |
||||
if (!("unknown".equalsIgnoreCase(strIp))) { |
||||
ip = strIp; |
||||
break; |
||||
} |
||||
} |
||||
} |
||||
return ip; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,24 @@ |
||||
package com.v1.config; |
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
||||
import javax.servlet.ServletContextEvent; |
||||
import javax.servlet.ServletContextListener; |
||||
import javax.servlet.annotation.WebListener; |
||||
|
||||
@WebListener |
||||
public class ConfigListener implements ServletContextListener { |
||||
|
||||
@Autowired |
||||
private SysConfig sysConfig; |
||||
|
||||
@Override |
||||
public void contextInitialized(ServletContextEvent sce) { |
||||
SysConst.setSysConfig(sysConfig); |
||||
} |
||||
|
||||
@Override |
||||
public void contextDestroyed(ServletContextEvent sce) { |
||||
} |
||||
|
||||
} |
@ -0,0 +1,49 @@ |
||||
package com.v1.config; |
||||
|
||||
import org.springframework.context.annotation.Bean; |
||||
import org.springframework.context.annotation.Configuration; |
||||
import org.springframework.web.cors.CorsConfiguration; |
||||
import org.springframework.web.cors.UrlBasedCorsConfigurationSource; |
||||
import org.springframework.web.filter.CorsFilter; |
||||
import org.springframework.web.servlet.config.annotation.CorsRegistry; |
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; |
||||
|
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
|
||||
/** |
||||
* @ClassName CorsConfig |
||||
* @Description: TODO () |
||||
* @Author 胡锐 |
||||
* @Date 2020/12/16 |
||||
**/ |
||||
@Configuration |
||||
public class CorsConfig extends WebMvcConfigurerAdapter { |
||||
@Override |
||||
public void addCorsMappings(CorsRegistry registry) { |
||||
registry.addMapping("/**") |
||||
.allowedOrigins("*") |
||||
.allowCredentials(true) |
||||
.allowedMethods("GET", "POST", "DELETE", "PUT") |
||||
.maxAge(3600); |
||||
} |
||||
private CorsConfiguration buildConfig() { |
||||
CorsConfiguration corsConfiguration = new CorsConfiguration(); |
||||
List<String> list = new ArrayList<>(); |
||||
list.add("*"); |
||||
corsConfiguration.setAllowedOrigins(list); |
||||
/* |
||||
// 请求常用的三种配置,*代表允许所有,当时你也可以自定义属性(比如header只能带什么,只能是post方式等等)
|
||||
*/ |
||||
corsConfiguration.addAllowedOrigin("*"); |
||||
corsConfiguration.addAllowedHeader("*"); |
||||
corsConfiguration.addAllowedMethod("*"); |
||||
return corsConfiguration; |
||||
} |
||||
@Bean |
||||
public CorsFilter corsFilter() { |
||||
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource(); |
||||
source.registerCorsConfiguration("/**", buildConfig()); |
||||
return new CorsFilter(source); |
||||
} |
||||
} |
@ -0,0 +1,26 @@ |
||||
package com.v1.config; |
||||
|
||||
import org.springframework.boot.web.servlet.MultipartConfigFactory; |
||||
import org.springframework.context.annotation.Bean; |
||||
import org.springframework.context.annotation.Configuration; |
||||
|
||||
import javax.servlet.MultipartConfigElement; |
||||
|
||||
@Configuration |
||||
public class MultipartConfig { |
||||
|
||||
/** |
||||
* 文件上传配置 |
||||
* @return |
||||
*/ |
||||
@Bean |
||||
public MultipartConfigElement multipartConfigElement() { |
||||
MultipartConfigFactory factory = new MultipartConfigFactory(); |
||||
//文件最大
|
||||
factory.setMaxFileSize("300MB"); //KB,MB
|
||||
//设置总上传数据总大小
|
||||
factory.setMaxRequestSize("350MB"); |
||||
return factory.createMultipartConfig(); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,109 @@ |
||||
package com.v1.config; |
||||
|
||||
import com.fasterxml.jackson.annotation.JsonAutoDetect; |
||||
import com.fasterxml.jackson.annotation.PropertyAccessor; |
||||
import com.fasterxml.jackson.databind.ObjectMapper; |
||||
import org.springframework.cache.annotation.CachingConfigurerSupport; |
||||
import org.springframework.cache.annotation.EnableCaching; |
||||
import org.springframework.context.annotation.Bean; |
||||
import org.springframework.context.annotation.Configuration; |
||||
import org.springframework.data.redis.connection.RedisConnectionFactory; |
||||
import org.springframework.data.redis.core.*; |
||||
import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer; |
||||
import org.springframework.data.redis.serializer.StringRedisSerializer; |
||||
|
||||
|
||||
@Configuration |
||||
@EnableCaching //开启注解
|
||||
public class RedisConfig extends CachingConfigurerSupport { |
||||
|
||||
/** |
||||
* retemplate相关配置 |
||||
* @param factory |
||||
* @return |
||||
*/ |
||||
@Bean |
||||
public RedisTemplate<String, Object> redisTemplate(RedisConnectionFactory factory) { |
||||
|
||||
RedisTemplate<String, Object> template = new RedisTemplate<>(); |
||||
// 配置连接工厂
|
||||
template.setConnectionFactory(factory); |
||||
|
||||
//使用Jackson2JsonRedisSerializer来序列化和反序列化redis的value值(默认使用JDK的序列化方式)
|
||||
Jackson2JsonRedisSerializer jacksonSeial = new Jackson2JsonRedisSerializer(Object.class); |
||||
|
||||
ObjectMapper om = new ObjectMapper(); |
||||
// 指定要序列化的域,field,get和set,以及修饰符范围,ANY是都有包括private和public
|
||||
om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY); |
||||
// 指定序列化输入的类型,类必须是非final修饰的,final修饰的类,比如String,Integer等会跑出异常
|
||||
om.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL); |
||||
jacksonSeial.setObjectMapper(om); |
||||
|
||||
// 值采用json序列化
|
||||
template.setValueSerializer(jacksonSeial); |
||||
//使用StringRedisSerializer来序列化和反序列化redis的key值
|
||||
template.setKeySerializer(new StringRedisSerializer()); |
||||
|
||||
// 设置hash key 和value序列化模式
|
||||
template.setHashKeySerializer(new StringRedisSerializer()); |
||||
template.setHashValueSerializer(jacksonSeial); |
||||
template.afterPropertiesSet(); |
||||
|
||||
return template; |
||||
} |
||||
|
||||
/** |
||||
* 对hash类型的数据操作 |
||||
* |
||||
* @param redisTemplate |
||||
* @return |
||||
*/ |
||||
@Bean |
||||
public HashOperations<String, String, Object> hashOperations(RedisTemplate<String, Object> redisTemplate) { |
||||
return redisTemplate.opsForHash(); |
||||
} |
||||
|
||||
/** |
||||
* 对redis字符串类型数据操作 |
||||
* |
||||
* @param redisTemplate |
||||
* @return |
||||
*/ |
||||
@Bean |
||||
public ValueOperations<String, Object> valueOperations(RedisTemplate<String, Object> redisTemplate) { |
||||
return redisTemplate.opsForValue(); |
||||
} |
||||
|
||||
/** |
||||
* 对链表类型的数据操作 |
||||
* |
||||
* @param redisTemplate |
||||
* @return |
||||
*/ |
||||
@Bean |
||||
public ListOperations<String, Object> listOperations(RedisTemplate<String, Object> redisTemplate) { |
||||
return redisTemplate.opsForList(); |
||||
} |
||||
|
||||
/** |
||||
* 对无序集合类型的数据操作 |
||||
* |
||||
* @param redisTemplate |
||||
* @return |
||||
*/ |
||||
@Bean |
||||
public SetOperations<String, Object> setOperations(RedisTemplate<String, Object> redisTemplate) { |
||||
return redisTemplate.opsForSet(); |
||||
} |
||||
|
||||
/** |
||||
* 对有序集合类型的数据操作 |
||||
* |
||||
* @param redisTemplate |
||||
* @return |
||||
*/ |
||||
@Bean |
||||
public ZSetOperations<String, Object> zSetOperations(RedisTemplate<String, Object> redisTemplate) { |
||||
return redisTemplate.opsForZSet(); |
||||
} |
||||
} |
@ -0,0 +1,4 @@ |
||||
package com.v1.config; |
||||
|
||||
public class SignatureConfig { |
||||
} |
@ -0,0 +1,47 @@ |
||||
package com.v1.config; |
||||
|
||||
import org.springframework.context.annotation.Bean; |
||||
import org.springframework.context.annotation.Configuration; |
||||
import springfox.documentation.builders.ApiInfoBuilder; |
||||
import springfox.documentation.builders.RequestHandlerSelectors; |
||||
import springfox.documentation.service.ApiInfo; |
||||
import springfox.documentation.service.Contact; |
||||
import springfox.documentation.spi.DocumentationType; |
||||
import springfox.documentation.spring.web.plugins.Docket; |
||||
import springfox.documentation.swagger2.annotations.EnableSwagger2; |
||||
|
||||
/** |
||||
* SwaggerConfig.java |
||||
* 项目名称: |
||||
* 包: |
||||
* 类名称: SwaggerConfig.java |
||||
* 类描述: 构建restful api接口文档 |
||||
* 创建人: |
||||
* 创建时间: 2017 下午4:23:45 |
||||
*/ |
||||
@Configuration |
||||
@EnableSwagger2 |
||||
public class SwaggerConfig |
||||
{ |
||||
|
||||
/** |
||||
* 描述api的基本信息 |
||||
* 基本信息会展现在文档页面中 |
||||
* @return [api的基本信息] |
||||
*/ |
||||
ApiInfo apiInfo() |
||||
{ |
||||
return new ApiInfoBuilder().title("hgj-BWeb").description("提供给管理平台的接口").termsOfServiceUrl("").version("1.0.0") |
||||
.contact(new Contact("", "", "")).build(); |
||||
} |
||||
|
||||
@Bean |
||||
public Docket customImplementation() |
||||
{ |
||||
return new Docket(DocumentationType.SWAGGER_2).select() |
||||
.apis(RequestHandlerSelectors.basePackage("com")) |
||||
.build().directModelSubstitute(org.joda.time.LocalDate.class, java.sql.Date.class) |
||||
.directModelSubstitute(org.joda.time.DateTime.class, java.util.Date.class).apiInfo(apiInfo()); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,13 @@ |
||||
package com.v1.config; |
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties; |
||||
import org.springframework.context.annotation.PropertySource; |
||||
import org.springframework.stereotype.Component; |
||||
|
||||
@Component("sysConfig") |
||||
@ConfigurationProperties |
||||
@PropertySource("classpath:/config.properties") |
||||
public class SysConfig { |
||||
|
||||
|
||||
} |
@ -0,0 +1,19 @@ |
||||
package com.v1.config; |
||||
|
||||
public class SysConst { |
||||
|
||||
private static SysConfig sysConfig; |
||||
|
||||
public static void setSysConfig(SysConfig arg){ |
||||
sysConfig = arg; |
||||
} |
||||
|
||||
public static SysConfig getSysConfig(){ |
||||
if (null == sysConfig) { |
||||
//防止空指针异常
|
||||
sysConfig = new SysConfig(); |
||||
return sysConfig; |
||||
} |
||||
return sysConfig; |
||||
} |
||||
} |
@ -0,0 +1,56 @@ |
||||
server: |
||||
port: 9902 |
||||
servlet: |
||||
context-path: /v1 |
||||
|
||||
#配置是否为debug模式,debug模式下,不开启权限校验 |
||||
debug: false |
||||
|
||||
#datasource数据源设置 |
||||
spring: |
||||
datasource: |
||||
url: jdbc:mysql://139.159.177.244:3306/hfkj?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false |
||||
username: root |
||||
password: HF123456. |
||||
type: com.alibaba.druid.pool.DruidDataSource |
||||
driver-class-name: com.mysql.jdbc.Driver |
||||
filters: stat |
||||
maxActive: 10 |
||||
initialSize: 5 |
||||
maxWait: 60000 |
||||
minIdle: 5 |
||||
timeBetweenEvictionRunsMillis: 60000 |
||||
minEvictableIdleTimeMillis: 300000 |
||||
validationQuery: select 'x' |
||||
testWhileIdle: true |
||||
testOnBorrow: false |
||||
testOnReturn: false |
||||
poolPreparedStatements: true |
||||
maxOpenPreparedStatements: 20 |
||||
redis: |
||||
database: 0 |
||||
host: 139.159.177.244 |
||||
port: 36379 |
||||
password: HF123456.Redis |
||||
timeout: 36000000 |
||||
jedis: |
||||
pool: |
||||
max-active: 20 |
||||
max-wait: -1 |
||||
max-idle: 10 |
||||
min-idle: 0 |
||||
#配置日期返回至前台为时间戳 |
||||
jackson: |
||||
serialization: |
||||
write-dates-as-timestamps: true |
||||
mybatis: |
||||
mapperLocations: |
||||
- classpath*:sqlmap*/*.xml |
||||
type-aliases-package: |
||||
org.springboot.sample.entity |
||||
|
||||
pagehelper: |
||||
helperDialect: mysql |
||||
reasonable: true |
||||
supportMethodsArguments: true |
||||
params: count=countSql |
@ -0,0 +1,72 @@ |
||||
<configuration> |
||||
<!-- %m输出的信息,%p日志级别,%t线程名,%d日期,%c类的全名,,,, --> |
||||
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> |
||||
<encoder> |
||||
<pattern>%d %p (%file:%line\)- %m%n</pattern> |
||||
<charset>UTF-8</charset> |
||||
</encoder> |
||||
</appender> |
||||
<appender name="baselog" |
||||
class="ch.qos.logback.core.rolling.RollingFileAppender"> |
||||
<File>log/base.log</File> |
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> |
||||
<fileNamePattern>log/base.log.%d.%i</fileNamePattern> |
||||
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"> |
||||
<!-- or whenever the file size reaches 64 MB --> |
||||
<maxFileSize>64 MB</maxFileSize> |
||||
</timeBasedFileNamingAndTriggeringPolicy> |
||||
</rollingPolicy> |
||||
<encoder> |
||||
<pattern> |
||||
%d %p (%file:%line\)- %m%n |
||||
</pattern> |
||||
<charset>UTF-8</charset> <!-- 此处设置字符集 --> |
||||
</encoder> |
||||
</appender> |
||||
<appender name="daolog" |
||||
class="ch.qos.logback.core.rolling.RollingFileAppender"> |
||||
<File>log/dao.log</File> |
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> |
||||
<fileNamePattern>log/dao.log.%d.%i</fileNamePattern> |
||||
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"> |
||||
<!-- or whenever the file size reaches 64 MB --> |
||||
<maxFileSize>64 MB</maxFileSize> |
||||
</timeBasedFileNamingAndTriggeringPolicy> |
||||
</rollingPolicy> |
||||
<encoder> |
||||
<pattern> |
||||
%d %p (%file:%line\)- %m%n |
||||
</pattern> |
||||
<charset>UTF-8</charset> <!-- 此处设置字符集 --> |
||||
</encoder> |
||||
</appender> |
||||
<appender name="errorlog" |
||||
class="ch.qos.logback.core.rolling.RollingFileAppender"> |
||||
<File>log/error.log</File> |
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> |
||||
<fileNamePattern>log/error.log.%d.%i</fileNamePattern> |
||||
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"> |
||||
<!-- or whenever the file size reaches 64 MB --> |
||||
<maxFileSize>64 MB</maxFileSize> |
||||
</timeBasedFileNamingAndTriggeringPolicy> |
||||
</rollingPolicy> |
||||
<encoder> |
||||
<pattern> |
||||
%d %p (%file:%line\)- %m%n |
||||
</pattern> |
||||
<charset>UTF-8</charset> <!-- 此处设置字符集 --> |
||||
</encoder> |
||||
</appender> |
||||
<root level="DEBUG"> |
||||
<appender-ref ref="STDOUT" /> |
||||
</root> |
||||
<logger name="com.hai" level="DEBUG"> |
||||
<appender-ref ref="baselog" /> |
||||
</logger> |
||||
<logger name="com.hai.dao" level="DEBUG"> |
||||
<appender-ref ref="daolog" /> |
||||
</logger> |
||||
<logger name="com.hai" level="ERROR"> |
||||
<appender-ref ref="errorlog" /> |
||||
</logger> |
||||
</configuration> |
@ -0,0 +1,56 @@ |
||||
server: |
||||
port: 9902 |
||||
servlet: |
||||
context-path: /v1 |
||||
|
||||
#配置是否为debug模式,debug模式下,不开启权限校验 |
||||
debug: false |
||||
|
||||
#datasource数据源设置 |
||||
spring: |
||||
datasource: |
||||
url: jdbc:mysql://122.9.135.148:3306/hsg?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false |
||||
username: root |
||||
password: HF123456. |
||||
type: com.alibaba.druid.pool.DruidDataSource |
||||
driver-class-name: com.mysql.jdbc.Driver |
||||
filters: stat |
||||
maxActive: 10 |
||||
initialSize: 5 |
||||
maxWait: 60000 |
||||
minIdle: 5 |
||||
timeBetweenEvictionRunsMillis: 60000 |
||||
minEvictableIdleTimeMillis: 300000 |
||||
validationQuery: select 'x' |
||||
testWhileIdle: true |
||||
testOnBorrow: false |
||||
testOnReturn: false |
||||
poolPreparedStatements: true |
||||
maxOpenPreparedStatements: 20 |
||||
redis: |
||||
database: 1 |
||||
host: 139.159.177.244 |
||||
port: 36379 |
||||
password: HF123456.Redis |
||||
timeout: 1000 |
||||
jedis: |
||||
pool: |
||||
max-active: 20 |
||||
max-wait: -1 |
||||
max-idle: 10 |
||||
min-idle: 0 |
||||
#配置日期返回至前台为时间戳 |
||||
jackson: |
||||
serialization: |
||||
write-dates-as-timestamps: true |
||||
mybatis: |
||||
mapperLocations: |
||||
- classpath*:sqlmap*/*.xml |
||||
type-aliases-package: |
||||
org.springboot.sample.entity |
||||
|
||||
pagehelper: |
||||
helperDialect: mysql |
||||
reasonable: true |
||||
supportMethodsArguments: true |
||||
params: count=countSql |
@ -0,0 +1,72 @@ |
||||
<configuration> |
||||
<!-- %m输出的信息,%p日志级别,%t线程名,%d日期,%c类的全名,,,, --> |
||||
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> |
||||
<encoder> |
||||
<pattern>%d %p (%file:%line\)- %m%n</pattern> |
||||
<charset>UTF-8</charset> |
||||
</encoder> |
||||
</appender> |
||||
<appender name="baselog" |
||||
class="ch.qos.logback.core.rolling.RollingFileAppender"> |
||||
<File>log/base.log</File> |
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> |
||||
<fileNamePattern>log/base.log.%d.%i</fileNamePattern> |
||||
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"> |
||||
<!-- or whenever the file size reaches 64 MB --> |
||||
<maxFileSize>64 MB</maxFileSize> |
||||
</timeBasedFileNamingAndTriggeringPolicy> |
||||
</rollingPolicy> |
||||
<encoder> |
||||
<pattern> |
||||
%d %p (%file:%line\)- %m%n |
||||
</pattern> |
||||
<charset>UTF-8</charset> <!-- 此处设置字符集 --> |
||||
</encoder> |
||||
</appender> |
||||
<appender name="daolog" |
||||
class="ch.qos.logback.core.rolling.RollingFileAppender"> |
||||
<File>log/dao.log</File> |
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> |
||||
<fileNamePattern>log/dao.log.%d.%i</fileNamePattern> |
||||
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"> |
||||
<!-- or whenever the file size reaches 64 MB --> |
||||
<maxFileSize>64 MB</maxFileSize> |
||||
</timeBasedFileNamingAndTriggeringPolicy> |
||||
</rollingPolicy> |
||||
<encoder> |
||||
<pattern> |
||||
%d %p (%file:%line\)- %m%n |
||||
</pattern> |
||||
<charset>UTF-8</charset> <!-- 此处设置字符集 --> |
||||
</encoder> |
||||
</appender> |
||||
<appender name="errorlog" |
||||
class="ch.qos.logback.core.rolling.RollingFileAppender"> |
||||
<File>log/error.log</File> |
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> |
||||
<fileNamePattern>log/error.log.%d.%i</fileNamePattern> |
||||
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"> |
||||
<!-- or whenever the file size reaches 64 MB --> |
||||
<maxFileSize>64 MB</maxFileSize> |
||||
</timeBasedFileNamingAndTriggeringPolicy> |
||||
</rollingPolicy> |
||||
<encoder> |
||||
<pattern> |
||||
%d %p (%file:%line\)- %m%n |
||||
</pattern> |
||||
<charset>UTF-8</charset> <!-- 此处设置字符集 --> |
||||
</encoder> |
||||
</appender> |
||||
<root level="DEBUG"> |
||||
<appender-ref ref="STDOUT" /> |
||||
</root> |
||||
<logger name="com.hai" level="DEBUG"> |
||||
<appender-ref ref="baselog" /> |
||||
</logger> |
||||
<logger name="com.hai.dao" level="DEBUG"> |
||||
<appender-ref ref="daolog" /> |
||||
</logger> |
||||
<logger name="com.hai" level="ERROR"> |
||||
<appender-ref ref="errorlog" /> |
||||
</logger> |
||||
</configuration> |
@ -0,0 +1,74 @@ |
||||
server: |
||||
port: 9902 |
||||
servlet: |
||||
context-path: /v1 |
||||
|
||||
#配置是否为debug模式,debug模式下,不开启权限校验 |
||||
debug: false |
||||
|
||||
#datasource数据源设置 |
||||
spring: |
||||
datasource: |
||||
url: jdbc:mysql://192.168.0.63:21100/hsg?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8 |
||||
username: hsg |
||||
password: HUfukeji123456!@# |
||||
type: com.alibaba.druid.pool.DruidDataSource |
||||
driver-class-name: com.mysql.jdbc.Driver |
||||
filters: stat |
||||
maxActive: 10 |
||||
initialSize: 5 |
||||
maxWait: 60000 |
||||
minIdle: 5 |
||||
timeBetweenEvictionRunsMillis: 60000 |
||||
minEvictableIdleTimeMillis: 300000 |
||||
validationQuery: select 'x' |
||||
testWhileIdle: true |
||||
testOnBorrow: false |
||||
testOnReturn: false |
||||
poolPreparedStatements: true |
||||
maxOpenPreparedStatements: 20 |
||||
redis: |
||||
database: 0 |
||||
host: 127.0.0.1 |
||||
port: 36379 |
||||
password: HF123456.Redis |
||||
timeout: 1000 |
||||
jedis: |
||||
pool: |
||||
max-active: 20 |
||||
max-wait: -1 |
||||
max-idle: 10 |
||||
min-idle: 0 |
||||
#thymelea模板配置 |
||||
thymeleaf: |
||||
prefix: classpath:/templates/ |
||||
suffix: .html |
||||
mode: HTML5 |
||||
encoding: UTF-8 |
||||
#热部署文件,页面不产生缓存,及时更新 |
||||
cache: false |
||||
#配置日期返回至前台为时间戳 |
||||
jackson: |
||||
serialization: |
||||
write-dates-as-timestamps: true |
||||
|
||||
|
||||
thymeleaf: |
||||
cache: false |
||||
prefix: classpath:/templates/ |
||||
suffix: .html |
||||
encoding: UTF-8 |
||||
content-type: text/html |
||||
mode: HTML5 |
||||
|
||||
mybatis: |
||||
mapperLocations: |
||||
- classpath*:sqlmap*/*.xml |
||||
type-aliases-package: |
||||
org.springboot.sample.entity |
||||
|
||||
pagehelper: |
||||
helperDialect: mysql |
||||
reasonable: true |
||||
supportMethodsArguments: true |
||||
params: count=countSql |
@ -0,0 +1,72 @@ |
||||
<configuration> |
||||
<!-- %m输出的信息,%p日志级别,%t线程名,%d日期,%c类的全名,,,, --> |
||||
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> |
||||
<encoder> |
||||
<pattern>%d %p (%file:%line\)- %m%n</pattern> |
||||
<charset>UTF-8</charset> |
||||
</encoder> |
||||
</appender> |
||||
<appender name="baselog" |
||||
class="ch.qos.logback.core.rolling.RollingFileAppender"> |
||||
<File>log/base.log</File> |
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> |
||||
<fileNamePattern>log/base.log.%d.%i</fileNamePattern> |
||||
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"> |
||||
<!-- or whenever the file size reaches 64 MB --> |
||||
<maxFileSize>64 MB</maxFileSize> |
||||
</timeBasedFileNamingAndTriggeringPolicy> |
||||
</rollingPolicy> |
||||
<encoder> |
||||
<pattern> |
||||
%d %p (%file:%line\)- %m%n |
||||
</pattern> |
||||
<charset>UTF-8</charset> <!-- 此处设置字符集 --> |
||||
</encoder> |
||||
</appender> |
||||
<appender name="daolog" |
||||
class="ch.qos.logback.core.rolling.RollingFileAppender"> |
||||
<File>log/dao.log</File> |
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> |
||||
<fileNamePattern>log/dao.log.%d.%i</fileNamePattern> |
||||
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"> |
||||
<!-- or whenever the file size reaches 64 MB --> |
||||
<maxFileSize>64 MB</maxFileSize> |
||||
</timeBasedFileNamingAndTriggeringPolicy> |
||||
</rollingPolicy> |
||||
<encoder> |
||||
<pattern> |
||||
%d %p (%file:%line\)- %m%n |
||||
</pattern> |
||||
<charset>UTF-8</charset> <!-- 此处设置字符集 --> |
||||
</encoder> |
||||
</appender> |
||||
<appender name="errorlog" |
||||
class="ch.qos.logback.core.rolling.RollingFileAppender"> |
||||
<File>log/error.log</File> |
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> |
||||
<fileNamePattern>log/error.log.%d.%i</fileNamePattern> |
||||
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"> |
||||
<!-- or whenever the file size reaches 64 MB --> |
||||
<maxFileSize>64 MB</maxFileSize> |
||||
</timeBasedFileNamingAndTriggeringPolicy> |
||||
</rollingPolicy> |
||||
<encoder> |
||||
<pattern> |
||||
%d %p (%file:%line\)- %m%n |
||||
</pattern> |
||||
<charset>UTF-8</charset> <!-- 此处设置字符集 --> |
||||
</encoder> |
||||
</appender> |
||||
<root level="DEBUG"> |
||||
<appender-ref ref="STDOUT" /> |
||||
</root> |
||||
<logger name="com.hai" level="DEBUG"> |
||||
<appender-ref ref="baselog" /> |
||||
</logger> |
||||
<logger name="com.hai.dao" level="DEBUG"> |
||||
<appender-ref ref="daolog" /> |
||||
</logger> |
||||
<logger name="com.hai" level="ERROR"> |
||||
<appender-ref ref="errorlog" /> |
||||
</logger> |
||||
</configuration> |
Loading…
Reference in new issue