Commit 40228d24 by zhanghj

V1.0.0--汽车共享服务提交用户中心,订单中心,公共服务,定时任务框架代码

git-svn-id: svn://192.168.3.233/frms/code/car-service/trunk/car-service@16761 aeb6102e-e053-11e5-9fec-f9ebc45caf4b
1 parent b1207334
Showing 47 changed files with 1805 additions and 9 deletions
...@@ -3,9 +3,9 @@ spring.profiles.active=local ...@@ -3,9 +3,9 @@ spring.profiles.active=local
server.display-name=car-service-manager server.display-name=car-service-manager
server.servlet.context-path=/carservice/manager server.servlet.context-path=/carservice/manager
server.port=8080 server.port=8090
##\u65e5\u5fd7 test ##\u65e5\u5fd7 test
logging.level.com.qurong.credit.sp=DEBUG logging.level.com.glsx.manager=DEBUG
logging.path=/data/java_log/jetty/car-service-manager logging.path=/data/java_log/jetty/car-service-manager
logging.config=classpath:logback-spring.xml logging.config=classpath:logback-spring.xml
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jdk1.8.0_171">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>car-service-ordercenter</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
</natures>
</projectDescription>
<?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">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>car-service</artifactId>
<groupId>com.glsx</groupId>
<version>1.0.0</version>
<relativePath>../pom.xml</relativePath>
</parent>
<groupId>com.glsx</groupId>
<artifactId>car-service-ordercenter</artifactId>
<version>1.0.0</version>
<name>car-service-ordercenter</name>
<!-- FIXME change it to the project's website -->
<url>http://www.example.com</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>com.glsx</groupId>
<artifactId>car-service-common</artifactId>
<version>1.0.0</version>
</dependency>
<!-- spring-boot-devtools -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>test</scope>
</dependency>
<!-- hibernate.validator -->
<dependency>
<groupId>org.hibernate.validator</groupId>
<artifactId>hibernate-validator</artifactId>
<version>6.0.13.Final</version>
</dependency>
</dependencies>
<build>
<pluginManagement><!-- lock down plugins versions to avoid using Maven
defaults (may be moved to parent pom) -->
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<fork>true</fork> <!-- 如果没有该配置,devtools不会生效 -->
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
package com.glsx.ordercenter;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.transaction.annotation.EnableTransactionManagement;
/**
*
* @Title Application.java
* @Package com.glsx.usercenter
* @Description TODO
* @author zhanghj
* @date 2019年1月16日 下午2:25:01
* @version 1.0.0
*/
@SpringBootApplication
@ServletComponentScan
@EnableTransactionManagement
@MapperScan(basePackages={"com.glsx.ordercenter.mapper"})
public class Application extends SpringBootServletInitializer{
/**
* 本地启动 ,内嵌tomcat方式
* @param args
*/
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
/**
* 打包项目,单独部署tomcat
*/
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
return builder.sources(Application.class);
}
}
package com.glsx.ordercenter.constants;
/**
*
* @Title ResultCodeEnum.java
* @Package com.glsx.manager.constants
* @Description TODO
* @author zhanghj
* @date 2018年12月24日 下午5:31:38
* @version 1.0.0
*/
public enum ResultCodeEnum {
SUCCESS(200, "成功"),
FAIL(400, "失败"),
ERROR(500, "系统异常"),
PARAM_ERROR(100, "参数错误"),
NOT_LOGIN(101, "用户未登录"),
TRY_AGAIN(102, "失败,请重试"),
;
/**
*状态码
*/
private int code;
/**
* 状态码对应的信息
*/
private String msg;
ResultCodeEnum(int code, String msg) {
this.code = code;
this.msg = msg;
}
public int getCode() {
return code;
}
public void setCode(int code) {
this.code = code;
}
public String getMsg() {
return msg;
}
public void setMsg(String msg) {
this.msg = msg;
}
}
package com.glsx.ordercenter.controller;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.glsx.common.constants.ResultObject;
import com.glsx.common.utils.Page;
import com.glsx.ordercenter.constants.ResultCodeEnum;
import com.glsx.ordercenter.pojo.Test;
import com.glsx.ordercenter.service.TestService;
import com.glsx.ordercenter.utils.PropertiesUtil;
@RestController
@RequestMapping(value="/test")
public class TestController {
@Autowired
private TestService testService;
@RequestMapping(value="/get", method={RequestMethod.GET, RequestMethod.POST})
public ResultObject index(Test test){
try{
test = testService.get(test);
}catch(Exception e){
}
return new ResultObject(ResultCodeEnum.SUCCESS.getCode(), ResultCodeEnum.SUCCESS.getMsg(), test);
}
@SuppressWarnings("resource")
@RequestMapping(value="/list", method={RequestMethod.GET, RequestMethod.POST})
public ResultObject list(@RequestParam(defaultValue = "1") int pageIndex, @RequestParam(defaultValue = "10") int pageSize){
Map<String, Object> result = new HashMap<String, Object>();
Page page = new Page(pageIndex, pageSize);
List<Test> list = testService.list(page);
com.github.pagehelper.Page<Test> pages = (com.github.pagehelper.Page<Test>) list;
page.setTotalCount((int)pages.getTotal());
result.put("page", page);
result.put("items", list);
return new ResultObject(ResultCodeEnum.SUCCESS.getCode(), ResultCodeEnum.SUCCESS.getMsg(), result);
}
@RequestMapping(value="/getProperty", method={RequestMethod.GET, RequestMethod.POST})
public ResultObject getProperty(String key){
String val = null;
try{
val = PropertiesUtil.getProperty(key);
}catch(Exception e){
}
return new ResultObject(ResultCodeEnum.SUCCESS.getCode(), ResultCodeEnum.SUCCESS.getMsg(), val);
}
@RequestMapping(value="/testException")
public ResultObject testException() throws Exception{
throw new Exception();
}
}
package com.glsx.ordercenter.exception;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import com.glsx.common.constants.ResultObject;
import com.glsx.ordercenter.constants.ResultCodeEnum;
/**
*
* @Title GlobalExceptionHandler.java
* @Package com.glsx.manager.exception
* @Description TODO 全局异常处理
* @author zhanghj
* @date 2018年12月24日 下午5:34:39
* @version 1.0.0
*/
@RestControllerAdvice
public class GlobalExceptionHandler {
private Logger logger = LoggerFactory.getLogger(GlobalExceptionHandler.class);
@ExceptionHandler(Exception.class)
public ResultObject exceptionHandler(Exception e){
logger.error("系统异常-->",e);
return new ResultObject(ResultCodeEnum.ERROR.getCode(), ResultCodeEnum.ERROR.getMsg());
}
}
package com.glsx.ordercenter.mapper;
import java.util.List;
import com.glsx.ordercenter.pojo.Test;
/**
*
* @Title TestMapper.java
* @Package com.glsx.manager.mapper
* @Description TODO
* @author zhanghj
* @date 2018年12月24日 下午5:24:10
* @version 1.0.0
*/
public interface TestMapper {
Test get(Test test);
List<Test> list();
}
package com.glsx.ordercenter.pojo;
public class Test {
private Integer id;
private String username;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
}
package com.glsx.ordercenter.service;
import java.util.List;
import com.glsx.common.utils.Page;
import com.glsx.ordercenter.pojo.Test;
/**
*
* @Title TestService.java
* @Package org.car.service.manager.service
* @Description TODO 测试service
* @author zhanghj
* @date 2018年12月24日 下午3:02:17
* @version
*/
public interface TestService {
Test get(Test test);
List<Test> list(Page page);
}
package com.glsx.ordercenter.service.impl;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.github.pagehelper.PageHelper;
import com.glsx.common.utils.Page;
import com.glsx.ordercenter.mapper.TestMapper;
import com.glsx.ordercenter.pojo.Test;
import com.glsx.ordercenter.service.TestService;
@Service
public class TestServiceImpl implements TestService{
@Autowired
private TestMapper testDao;
@Override
public Test get(Test test) {
// TODO Auto-generated method stub
return testDao.get(test);
}
@Override
public List<Test> list(Page page) {
// TODO Auto-generated method stub
if (page != null) {
PageHelper.startPage(page.getPageIndex(), page.getPageSize(), true);
}
return testDao.list();
}
}
package com.glsx.ordercenter.utils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Component;
/**
*
* @Title PropertiesUtil.java
* @Package com.glsx.manager.utils
* @Description TODO 读取配置文件属性值
* @author zhanghj
* @date 2018年12月24日 下午5:38:42
* @version 1.0.0
*/
@Component
public class PropertiesUtil {
private static Environment env;
@Autowired
public void setEnv(Environment env) {
PropertiesUtil.env = env;
}
public static String getProperty(String key){
return env.getProperty(key);
}
public static String getProperty(String key, String defaultVal){
return env.getProperty(key, defaultVal);
}
}
##\u5f00\u53d1\u4e2d\u9700\u8981\u8bfb\u53d6\u7684\u914d\u7f6e\u6587\u4ef6
spring.profiles.active=local
server.display-name=car-service-ordercenter
server.servlet.context-path=/carservice/ordercenter
server.port=8092
##\u65e5\u5fd7 test
logging.level.com.glsx.ordercenter=DEBUG
logging.path=/data/java_log/jetty/car-service-ordercenter
logging.config=classpath:logback-spring.xml
spring.datasource.name=dev
spring.datasource.url=jdbc:mysql://192.168.0.39:3306/glsx_car_service
spring.datasource.username=root
spring.datasource.password=123456
#spring.datasource.connectionProperties="config.decrypt=true;config.decrypt.key=MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBANj300lzSmW05DuzVoluFG6oza+WlEbv2aYCQA2+pkf0mE4p19UAcxfY/BweOyJ6TBNoY5XebPqoiav5lsKVD6sCAwEAAQ=="
spring.datasource.type=com.alibaba.druid.pool.DruidDataSource
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.datasource.filters=stat
spring.datasource.maxActive=20
spring.datasource.initialSize=5
spring.datasource.maxWait=60000
spring.datasource.minIdle=5
spring.datasource.timeBetweenEvictionRunsMillis=60000
spring.datasource.minEvictableIdleTimeMillis=300000
spring.datasource.validationQuery=select 'x'
spring.datasource.testWhileIdle=true
spring.datasource.testOnBorrow=false
spring.datasource.testOnReturn=false
spring.datasource.poolPreparedStatements=true
spring.datasource.maxOpenPreparedStatements=50
#mybatis\u96c6\u6210\u914d\u7f6e
mybatis.mapperLocations=classpath*:mapper/*.xml
mybatis.typeAliasesPackage=com.glsx.ordercenter.pojo
#pagehelper
pagehelper.helperDialect=mysql
pagehelper.supportMethodsArguments=true
pagehelper.params=count=countSql
spring.jmx.enabled=false
# MULTIPART (MultipartProperties)
# Whether to enable support of multipart uploads.
spring.servlet.multipart.enabled=true
# Max file size. Values can use the suffixes "MB" or "KB" to indicate megabytes or kilobytes, respectively.
spring.servlet.multipart.max-file-size=20MB
# Max request size. Values can use the suffixes "MB" or "KB" to indicate megabytes or kilobytes, respectively.
spring.servlet.multipart.max-request-size=20MB
# REDIS (RedisProperties)
# Database index used by the connection factory.
spring.redis.database=0
# Redis server host.
spring.redis.host=192.168.0.39
# Maximum number of connections that can be allocated by the pool at a given time. Use a negative value for no limit.
spring.redis.lettuce.pool.max-active=32
# Maximum number of "idle" connections in the pool. Use a negative value to indicate an unlimited number of idle connections.
spring.redis.lettuce.pool.max-idle=32
# Maximum amount of time a connection allocation should block before throwing an exception when the pool is exhausted. Use a negative value to block indefinitely.
spring.redis.lettuce.pool.max-wait=-1ms
# Target for the minimum number of idle connections to maintain in the pool. This setting only has an effect if it is positive.
spring.redis.lettuce.pool.min-idle=0
# Shutdown timeout.
spring.redis.lettuce.shutdown-timeout=100ms
#Login password of the redis server.
spring.redis.password=hhxredis
# Redis server port.
spring.redis.port=6379
#Whether to enable SSL support.
spring.redis.ssl=false
# Connection timeout.
spring.redis.timeout=6000ms
#\u77ed\u4fe1
#sms.url=http://192.168.3.206:8118/router111
#sms.url=http://qcdidicb.glsx.net:7060/router
sms.source=frms_sms_assign
##fastdfs
fdfs.soTimeout=1500
fdfs.connectTimeout=600
fdfs.thumbImage.width=150
fdfs.thumbImage.height=150
fdfs.trackerList=192.168.0.63:22122
#fdfs_tracker_nginx_port=80
fdfs_tracker_nginx_domain=http://192.168.0.63
##freemarker
spring.freemarker.cache=false
spring.freemarker.charset=UTF-8
spring.freemarker.check-template-location=true
spring.freemarker.content-type=text/html
spring.freemarker.enabled=true
spring.freemarker.suffix=.ftl
spring.freemarker.template-loader-path=classpath:/templates
#\u9759\u6001\u8d44\u6e90\u8def\u5f84
spring.mvc.static-path-pattern=/**
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<springProperty scope="context" name="log.path" source="logging.path" />
<property name="log.pattern" value="%d{yyyy-MM-dd} %d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n" />
<!-- 控制台输出 -->
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>${log.pattern}</pattern>
</encoder>
</appender>
<!-- 系统日志输出 -->
<appender name="file_info" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.path}/sys-info.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 按天回滚 daily -->
<fileNamePattern>${log.path}/sys-info.%d{yyyy-MM-dd}.log</fileNamePattern>
<!-- 日志最大的历史 60天 -->
<maxHistory>60</maxHistory>
</rollingPolicy>
<encoder>
<pattern>${log.pattern}</pattern>
</encoder>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>INFO</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<appender name="file_error" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.path}/sys-error.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>${log.path}/sys-error.%d{yyyy-MM-dd}.log</fileNamePattern>
<!-- 日志最大的历史 60天 -->
<maxHistory>60</maxHistory>
</rollingPolicy>
<encoder>
<pattern>${log.pattern}</pattern>
</encoder>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>ERROR</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<!-- 用户访问日志输出 -->
<appender name="sys-user" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.path}/sys-user.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 按天回滚 daily -->
<fileNamePattern>${log.path}/sys-user.%d{yyyy-MM-dd}.log</fileNamePattern>
<!-- 日志最大的历史 60天 -->
<maxHistory>60</maxHistory>
</rollingPolicy>
<encoder>
<pattern>${log.pattern}</pattern>
</encoder>
</appender>
<!-- 显示形成的sql、使用的参数、结果集 -->
<!--
<logger name="java.sql" level="debug" />
<logger name="org.springframework.jdbc" level="debug" />
-->
<logger name="com.qurong" level="info" />
<root level="info">
<appender-ref ref="console" />
</root>
<!--系统操作日志-->
<root level="info">
<appender-ref ref="file_info" />
<appender-ref ref="file_error" />
</root>
<!--系统用户操作日志-->
<logger name="sys-user" level="info">
<appender-ref ref="sys-user"/>
</logger>
</configuration>
\ No newline at end of file \ No newline at end of file
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.glsx.ordercenter.mapper.TestMapper" >
<resultMap id="baseUserResultMap" type="com.glsx.ordercenter.pojo.Test" >
<id column="id" property="id"/>
<result column="username" property="username"/>
</resultMap>
<select id="get" parameterType="com.glsx.ordercenter.pojo.Test" resultMap="baseUserResultMap">
select
u.id, u.username
from sys_user u
where id = #{id}
</select>
<select id="list" resultMap="baseUserResultMap">
select
u.id, u.username
from sys_user u
</select>
</mapper>
\ No newline at end of file \ No newline at end of file
package com.glsx.ordercenter;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
/**
* Unit test for simple App.
*/
public class AppTest
{
/**
* Rigorous Test :-)
*/
@Test
public void shouldAnswerWithTrue()
{
assertTrue( true );
}
}
<?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">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>car-service</artifactId>
<groupId>com.glsx</groupId>
<version>1.0.0</version>
<relativePath>../pom.xml</relativePath>
</parent>
<groupId>com.glsx</groupId>
<artifactId>car-service-publicservice</artifactId>
<version>1.0.0</version>
<name>car-service-publicservice</name>
<!-- FIXME change it to the project's website -->
<url>http://www.example.com</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>com.glsx</groupId>
<artifactId>car-service-common</artifactId>
<version>1.0.0</version>
</dependency>
<!-- spring-boot-devtools -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<pluginManagement><!-- lock down plugins versions to avoid using Maven
defaults (may be moved to parent pom) -->
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<fork>true</fork> <!-- 如果没有该配置,devtools不会生效 -->
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
\ No newline at end of file \ No newline at end of file
package com.glsx.publicservice;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.transaction.annotation.EnableTransactionManagement;
/**
*
* @Title Application.java
* @Package com.glsx.usercenter
* @Description TODO
* @author zhanghj
* @date 2019年1月16日 下午2:25:01
* @version 1.0.0
*/
@SpringBootApplication
@ServletComponentScan
@EnableTransactionManagement
@MapperScan(basePackages={"com.glsx.publicservice.mapper"})
public class Application extends SpringBootServletInitializer{
/**
* 本地启动 ,内嵌tomcat方式
* @param args
*/
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
/**
* 打包项目,单独部署tomcat
*/
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
return builder.sources(Application.class);
}
}
##\u5f00\u53d1\u4e2d\u9700\u8981\u8bfb\u53d6\u7684\u914d\u7f6e\u6587\u4ef6
spring.profiles.active=local
server.display-name=car-service-publicservice
server.servlet.context-path=/carservice/publicservice
server.port=8093
##\u65e5\u5fd7 test
logging.level.com.glsx.usercenter=DEBUG
logging.path=/data/java_log/jetty/car-service-publicservice
logging.config=classpath:logback-spring.xml
spring.datasource.name=dev
spring.datasource.url=jdbc:mysql://192.168.0.39:3306/glsx_car_service
spring.datasource.username=root
spring.datasource.password=123456
#spring.datasource.connectionProperties="config.decrypt=true;config.decrypt.key=MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBANj300lzSmW05DuzVoluFG6oza+WlEbv2aYCQA2+pkf0mE4p19UAcxfY/BweOyJ6TBNoY5XebPqoiav5lsKVD6sCAwEAAQ=="
spring.datasource.type=com.alibaba.druid.pool.DruidDataSource
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.datasource.filters=stat
spring.datasource.maxActive=20
spring.datasource.initialSize=5
spring.datasource.maxWait=60000
spring.datasource.minIdle=5
spring.datasource.timeBetweenEvictionRunsMillis=60000
spring.datasource.minEvictableIdleTimeMillis=300000
spring.datasource.validationQuery=select 'x'
spring.datasource.testWhileIdle=true
spring.datasource.testOnBorrow=false
spring.datasource.testOnReturn=false
spring.datasource.poolPreparedStatements=true
spring.datasource.maxOpenPreparedStatements=50
#mybatis\u96c6\u6210\u914d\u7f6e
mybatis.mapperLocations=classpath*:mapper/*.xml
mybatis.typeAliasesPackage=com.glsx.usercenter.pojo
#pagehelper
pagehelper.helperDialect=mysql
pagehelper.supportMethodsArguments=true
pagehelper.params=count=countSql
spring.jmx.enabled=false
# MULTIPART (MultipartProperties)
# Whether to enable support of multipart uploads.
spring.servlet.multipart.enabled=true
# Max file size. Values can use the suffixes "MB" or "KB" to indicate megabytes or kilobytes, respectively.
spring.servlet.multipart.max-file-size=20MB
# Max request size. Values can use the suffixes "MB" or "KB" to indicate megabytes or kilobytes, respectively.
spring.servlet.multipart.max-request-size=20MB
# REDIS (RedisProperties)
# Database index used by the connection factory.
spring.redis.database=0
# Redis server host.
spring.redis.host=192.168.0.39
# Maximum number of connections that can be allocated by the pool at a given time. Use a negative value for no limit.
spring.redis.lettuce.pool.max-active=32
# Maximum number of "idle" connections in the pool. Use a negative value to indicate an unlimited number of idle connections.
spring.redis.lettuce.pool.max-idle=32
# Maximum amount of time a connection allocation should block before throwing an exception when the pool is exhausted. Use a negative value to block indefinitely.
spring.redis.lettuce.pool.max-wait=-1ms
# Target for the minimum number of idle connections to maintain in the pool. This setting only has an effect if it is positive.
spring.redis.lettuce.pool.min-idle=0
# Shutdown timeout.
spring.redis.lettuce.shutdown-timeout=100ms
#Login password of the redis server.
spring.redis.password=hhxredis
# Redis server port.
spring.redis.port=6379
#Whether to enable SSL support.
spring.redis.ssl=false
# Connection timeout.
spring.redis.timeout=6000ms
#\u77ed\u4fe1
#sms.url=http://192.168.3.206:8118/router111
#sms.url=http://qcdidicb.glsx.net:7060/router
sms.source=frms_sms_assign
##fastdfs
fdfs.soTimeout=1500
fdfs.connectTimeout=600
fdfs.thumbImage.width=150
fdfs.thumbImage.height=150
fdfs.trackerList=192.168.0.63:22122
#fdfs_tracker_nginx_port=80
fdfs_tracker_nginx_domain=http://192.168.0.63
##freemarker
spring.freemarker.cache=false
spring.freemarker.charset=UTF-8
spring.freemarker.check-template-location=true
spring.freemarker.content-type=text/html
spring.freemarker.enabled=true
spring.freemarker.suffix=.ftl
spring.freemarker.template-loader-path=classpath:/templates
#\u9759\u6001\u8d44\u6e90\u8def\u5f84
spring.mvc.static-path-pattern=/**
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<springProperty scope="context" name="log.path" source="logging.path" />
<property name="log.pattern" value="%d{yyyy-MM-dd} %d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n" />
<!-- 控制台输出 -->
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>${log.pattern}</pattern>
</encoder>
</appender>
<!-- 系统日志输出 -->
<appender name="file_info" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.path}/sys-info.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 按天回滚 daily -->
<fileNamePattern>${log.path}/sys-info.%d{yyyy-MM-dd}.log</fileNamePattern>
<!-- 日志最大的历史 60天 -->
<maxHistory>60</maxHistory>
</rollingPolicy>
<encoder>
<pattern>${log.pattern}</pattern>
</encoder>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>INFO</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<appender name="file_error" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.path}/sys-error.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>${log.path}/sys-error.%d{yyyy-MM-dd}.log</fileNamePattern>
<!-- 日志最大的历史 60天 -->
<maxHistory>60</maxHistory>
</rollingPolicy>
<encoder>
<pattern>${log.pattern}</pattern>
</encoder>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>ERROR</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<!-- 用户访问日志输出 -->
<appender name="sys-user" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.path}/sys-user.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 按天回滚 daily -->
<fileNamePattern>${log.path}/sys-user.%d{yyyy-MM-dd}.log</fileNamePattern>
<!-- 日志最大的历史 60天 -->
<maxHistory>60</maxHistory>
</rollingPolicy>
<encoder>
<pattern>${log.pattern}</pattern>
</encoder>
</appender>
<!-- 显示形成的sql、使用的参数、结果集 -->
<!--
<logger name="java.sql" level="debug" />
<logger name="org.springframework.jdbc" level="debug" />
-->
<logger name="com.qurong" level="info" />
<root level="info">
<appender-ref ref="console" />
</root>
<!--系统操作日志-->
<root level="info">
<appender-ref ref="file_info" />
<appender-ref ref="file_error" />
</root>
<!--系统用户操作日志-->
<logger name="sys-user" level="info">
<appender-ref ref="sys-user"/>
</logger>
</configuration>
\ No newline at end of file \ No newline at end of file
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.glsx.usercenter.mapper.TestMapper" >
<resultMap id="baseUserResultMap" type="com.glsx.usercenter.pojo.Test" >
<id column="id" property="id"/>
<result column="username" property="username"/>
</resultMap>
<select id="get" parameterType="com.glsx.usercenter.pojo.Test" resultMap="baseUserResultMap">
select
u.id, u.username
from sys_user u
where id = #{id}
</select>
<select id="list" resultMap="baseUserResultMap">
select
u.id, u.username
from sys_user u
</select>
</mapper>
\ No newline at end of file \ No newline at end of file
package com.glsx.publicservice;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
/**
* Unit test for simple App.
*/
public class AppTest
{
/**
* Rigorous Test :-)
*/
@Test
public void shouldAnswerWithTrue()
{
assertTrue( true );
}
}
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>car-service-task</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
</natures>
</projectDescription>
<?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">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>car-service</artifactId>
<groupId>com.glsx</groupId>
<version>1.0.0</version>
</parent>
<groupId>com.glsx</groupId>
<artifactId>car-service-task</artifactId>
<version>1.0.0</version>
<name>car-service-task</name>
<!-- FIXME change it to the project's website -->
<url>http://www.example.com</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
<plugins>
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.0.0</version>
</plugin>
<!-- see http://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging -->
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.2</version>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.20.1</version>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>3.0.2</version>
</plugin>
<plugin>
<artifactId>maven-install-plugin</artifactId>
<version>2.5.2</version>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
package com.glsx.task;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.transaction.annotation.EnableTransactionManagement;
/**
*
* @Title Application.java
* @Package com.glsx.usercenter
* @Description TODO
* @author zhanghj
* @date 2019年1月16日 下午2:25:01
* @version 1.0.0
*/
@SpringBootApplication
@ServletComponentScan
@EnableTransactionManagement
@MapperScan(basePackages={"com.glsx.task.mapper"})
public class Application extends SpringBootServletInitializer{
/**
* 本地启动 ,内嵌tomcat方式
* @param args
*/
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
/**
* 打包项目,单独部署tomcat
*/
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
return builder.sources(Application.class);
}
}
package com.glsx.task;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
/**
* Unit test for simple App.
*/
public class AppTest
{
/**
* Rigorous Test :-)
*/
@Test
public void shouldAnswerWithTrue()
{
assertTrue( true );
}
}
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jdk1.8.0_171">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>car-service-usercenter</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
</natures>
</projectDescription>
<?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">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>car-service</artifactId>
<groupId>com.glsx</groupId>
<version>1.0.0</version>
<relativePath>../pom.xml</relativePath>
</parent>
<groupId>com.glsx</groupId>
<artifactId>car-service-usercenter</artifactId>
<version>1.0.0</version>
<name>car-service-usercenter</name>
<!-- FIXME change it to the project's website -->
<url>http://www.example.com</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>com.glsx</groupId>
<artifactId>car-service-common</artifactId>
<version>1.0.0</version>
</dependency>
<!-- spring-boot-devtools -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>test</scope>
</dependency>
<!-- hibernate.validator -->
<dependency>
<groupId>org.hibernate.validator</groupId>
<artifactId>hibernate-validator</artifactId>
<version>6.0.13.Final</version>
</dependency>
</dependencies>
<build>
<pluginManagement><!-- lock down plugins versions to avoid using Maven
defaults (may be moved to parent pom) -->
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<fork>true</fork> <!-- 如果没有该配置,devtools不会生效 -->
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
package com.glsx.usercenter;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.transaction.annotation.EnableTransactionManagement;
/**
*
* @Title Application.java
* @Package com.glsx.usercenter
* @Description TODO
* @author zhanghj
* @date 2019年1月16日 下午2:25:01
* @version 1.0.0
*/
@SpringBootApplication
@ServletComponentScan
@EnableTransactionManagement
@MapperScan(basePackages={"com.glsx.usercenter.mapper"})
public class Application extends SpringBootServletInitializer{
/**
* 本地启动 ,内嵌tomcat方式
* @param args
*/
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
/**
* 打包项目,单独部署tomcat
*/
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
return builder.sources(Application.class);
}
}
package com.glsx.usercenter.constants;
/**
*
* @Title ResultCodeEnum.java
* @Package com.glsx.manager.constants
* @Description TODO
* @author zhanghj
* @date 2018年12月24日 下午5:31:38
* @version 1.0.0
*/
public enum ResultCodeEnum {
SUCCESS(200, "成功"),
FAIL(400, "失败"),
ERROR(500, "系统异常"),
PARAM_ERROR(100, "参数错误"),
NOT_LOGIN(101, "用户未登录"),
TRY_AGAIN(102, "失败,请重试"),
;
/**
*状态码
*/
private int code;
/**
* 状态码对应的信息
*/
private String msg;
ResultCodeEnum(int code, String msg) {
this.code = code;
this.msg = msg;
}
public int getCode() {
return code;
}
public void setCode(int code) {
this.code = code;
}
public String getMsg() {
return msg;
}
public void setMsg(String msg) {
this.msg = msg;
}
}
package com.glsx.usercenter.controller;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.glsx.common.constants.ResultObject;
import com.glsx.common.utils.Page;
import com.glsx.usercenter.constants.ResultCodeEnum;
import com.glsx.usercenter.pojo.Test;
import com.glsx.usercenter.service.TestService;
import com.glsx.usercenter.utils.PropertiesUtil;
@RestController
@RequestMapping(value="/test")
public class TestController {
@Autowired
private TestService testService;
@RequestMapping(value="/get", method={RequestMethod.GET, RequestMethod.POST})
public ResultObject index(Test test){
try{
test = testService.get(test);
}catch(Exception e){
}
return new ResultObject(ResultCodeEnum.SUCCESS.getCode(), ResultCodeEnum.SUCCESS.getMsg(), test);
}
@SuppressWarnings("resource")
@RequestMapping(value="/list", method={RequestMethod.GET, RequestMethod.POST})
public ResultObject list(@RequestParam(defaultValue = "1") int pageIndex, @RequestParam(defaultValue = "10") int pageSize){
Map<String, Object> result = new HashMap<String, Object>();
Page page = new Page(pageIndex, pageSize);
List<Test> list = testService.list(page);
com.github.pagehelper.Page<Test> pages = (com.github.pagehelper.Page<Test>) list;
page.setTotalCount((int)pages.getTotal());
result.put("page", page);
result.put("items", list);
return new ResultObject(ResultCodeEnum.SUCCESS.getCode(), ResultCodeEnum.SUCCESS.getMsg(), result);
}
@RequestMapping(value="/getProperty", method={RequestMethod.GET, RequestMethod.POST})
public ResultObject getProperty(String key){
String val = null;
try{
val = PropertiesUtil.getProperty(key);
}catch(Exception e){
}
return new ResultObject(ResultCodeEnum.SUCCESS.getCode(), ResultCodeEnum.SUCCESS.getMsg(), val);
}
@RequestMapping(value="/testException")
public ResultObject testException() throws Exception{
throw new Exception();
}
}
package com.glsx.usercenter.exception;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import com.glsx.common.constants.ResultObject;
import com.glsx.usercenter.constants.ResultCodeEnum;
/**
*
* @Title GlobalExceptionHandler.java
* @Package com.glsx.manager.exception
* @Description TODO 全局异常处理
* @author zhanghj
* @date 2018年12月24日 下午5:34:39
* @version 1.0.0
*/
@RestControllerAdvice
public class GlobalExceptionHandler {
private Logger logger = LoggerFactory.getLogger(GlobalExceptionHandler.class);
@ExceptionHandler(Exception.class)
public ResultObject exceptionHandler(Exception e){
logger.error("系统异常-->",e);
return new ResultObject(ResultCodeEnum.ERROR.getCode(), ResultCodeEnum.ERROR.getMsg());
}
}
package com.glsx.usercenter.mapper;
import java.util.List;
import com.glsx.usercenter.pojo.Test;
/**
*
* @Title TestMapper.java
* @Package com.glsx.manager.mapper
* @Description TODO
* @author zhanghj
* @date 2018年12月24日 下午5:24:10
* @version 1.0.0
*/
public interface TestMapper {
Test get(Test test);
List<Test> list();
}
package com.glsx.usercenter.pojo;
public class Test {
private Integer id;
private String username;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
}
package com.glsx.usercenter.service;
import java.util.List;
import com.glsx.common.utils.Page;
import com.glsx.usercenter.pojo.Test;
/**
*
* @Title TestService.java
* @Package org.car.service.manager.service
* @Description TODO 测试service
* @author zhanghj
* @date 2018年12月24日 下午3:02:17
* @version
*/
public interface TestService {
Test get(Test test);
List<Test> list(Page page);
}
package com.glsx.usercenter.service.impl;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.github.pagehelper.PageHelper;
import com.glsx.common.utils.Page;
import com.glsx.usercenter.mapper.TestMapper;
import com.glsx.usercenter.pojo.Test;
import com.glsx.usercenter.service.TestService;
@Service
public class TestServiceImpl implements TestService{
@Autowired
private TestMapper testDao;
@Override
public Test get(Test test) {
// TODO Auto-generated method stub
return testDao.get(test);
}
@Override
public List<Test> list(Page page) {
// TODO Auto-generated method stub
if (page != null) {
PageHelper.startPage(page.getPageIndex(), page.getPageSize(), true);
}
return testDao.list();
}
}
package com.glsx.usercenter.utils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Component;
/**
*
* @Title PropertiesUtil.java
* @Package com.glsx.manager.utils
* @Description TODO 读取配置文件属性值
* @author zhanghj
* @date 2018年12月24日 下午5:38:42
* @version 1.0.0
*/
@Component
public class PropertiesUtil {
private static Environment env;
@Autowired
public void setEnv(Environment env) {
PropertiesUtil.env = env;
}
public static String getProperty(String key){
return env.getProperty(key);
}
public static String getProperty(String key, String defaultVal){
return env.getProperty(key, defaultVal);
}
}
##\u5f00\u53d1\u4e2d\u9700\u8981\u8bfb\u53d6\u7684\u914d\u7f6e\u6587\u4ef6
spring.profiles.active=local
server.display-name=car-service-usercenter
server.servlet.context-path=/carservice/usercenter
server.port=8091
##\u65e5\u5fd7 test
logging.level.com.glsx.usercenter=DEBUG
logging.path=/data/java_log/jetty/car-service-usercenter
logging.config=classpath:logback-spring.xml
spring.datasource.name=dev
spring.datasource.url=jdbc:mysql://192.168.0.39:3306/glsx_car_service
spring.datasource.username=root
spring.datasource.password=123456
#spring.datasource.connectionProperties="config.decrypt=true;config.decrypt.key=MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBANj300lzSmW05DuzVoluFG6oza+WlEbv2aYCQA2+pkf0mE4p19UAcxfY/BweOyJ6TBNoY5XebPqoiav5lsKVD6sCAwEAAQ=="
spring.datasource.type=com.alibaba.druid.pool.DruidDataSource
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.datasource.filters=stat
spring.datasource.maxActive=20
spring.datasource.initialSize=5
spring.datasource.maxWait=60000
spring.datasource.minIdle=5
spring.datasource.timeBetweenEvictionRunsMillis=60000
spring.datasource.minEvictableIdleTimeMillis=300000
spring.datasource.validationQuery=select 'x'
spring.datasource.testWhileIdle=true
spring.datasource.testOnBorrow=false
spring.datasource.testOnReturn=false
spring.datasource.poolPreparedStatements=true
spring.datasource.maxOpenPreparedStatements=50
#mybatis\u96c6\u6210\u914d\u7f6e
mybatis.mapperLocations=classpath*:mapper/*.xml
mybatis.typeAliasesPackage=com.glsx.usercenter.pojo
#pagehelper
pagehelper.helperDialect=mysql
pagehelper.supportMethodsArguments=true
pagehelper.params=count=countSql
spring.jmx.enabled=false
# MULTIPART (MultipartProperties)
# Whether to enable support of multipart uploads.
spring.servlet.multipart.enabled=true
# Max file size. Values can use the suffixes "MB" or "KB" to indicate megabytes or kilobytes, respectively.
spring.servlet.multipart.max-file-size=20MB
# Max request size. Values can use the suffixes "MB" or "KB" to indicate megabytes or kilobytes, respectively.
spring.servlet.multipart.max-request-size=20MB
# REDIS (RedisProperties)
# Database index used by the connection factory.
spring.redis.database=0
# Redis server host.
spring.redis.host=192.168.0.39
# Maximum number of connections that can be allocated by the pool at a given time. Use a negative value for no limit.
spring.redis.lettuce.pool.max-active=32
# Maximum number of "idle" connections in the pool. Use a negative value to indicate an unlimited number of idle connections.
spring.redis.lettuce.pool.max-idle=32
# Maximum amount of time a connection allocation should block before throwing an exception when the pool is exhausted. Use a negative value to block indefinitely.
spring.redis.lettuce.pool.max-wait=-1ms
# Target for the minimum number of idle connections to maintain in the pool. This setting only has an effect if it is positive.
spring.redis.lettuce.pool.min-idle=0
# Shutdown timeout.
spring.redis.lettuce.shutdown-timeout=100ms
#Login password of the redis server.
spring.redis.password=hhxredis
# Redis server port.
spring.redis.port=6379
#Whether to enable SSL support.
spring.redis.ssl=false
# Connection timeout.
spring.redis.timeout=6000ms
#\u77ed\u4fe1
#sms.url=http://192.168.3.206:8118/router111
#sms.url=http://qcdidicb.glsx.net:7060/router
sms.source=frms_sms_assign
##fastdfs
fdfs.soTimeout=1500
fdfs.connectTimeout=600
fdfs.thumbImage.width=150
fdfs.thumbImage.height=150
fdfs.trackerList=192.168.0.63:22122
#fdfs_tracker_nginx_port=80
fdfs_tracker_nginx_domain=http://192.168.0.63
##freemarker
spring.freemarker.cache=false
spring.freemarker.charset=UTF-8
spring.freemarker.check-template-location=true
spring.freemarker.content-type=text/html
spring.freemarker.enabled=true
spring.freemarker.suffix=.ftl
spring.freemarker.template-loader-path=classpath:/templates
#\u9759\u6001\u8d44\u6e90\u8def\u5f84
spring.mvc.static-path-pattern=/**
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<springProperty scope="context" name="log.path" source="logging.path" />
<property name="log.pattern" value="%d{yyyy-MM-dd} %d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n" />
<!-- 控制台输出 -->
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>${log.pattern}</pattern>
</encoder>
</appender>
<!-- 系统日志输出 -->
<appender name="file_info" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.path}/sys-info.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 按天回滚 daily -->
<fileNamePattern>${log.path}/sys-info.%d{yyyy-MM-dd}.log</fileNamePattern>
<!-- 日志最大的历史 60天 -->
<maxHistory>60</maxHistory>
</rollingPolicy>
<encoder>
<pattern>${log.pattern}</pattern>
</encoder>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>INFO</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<appender name="file_error" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.path}/sys-error.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>${log.path}/sys-error.%d{yyyy-MM-dd}.log</fileNamePattern>
<!-- 日志最大的历史 60天 -->
<maxHistory>60</maxHistory>
</rollingPolicy>
<encoder>
<pattern>${log.pattern}</pattern>
</encoder>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>ERROR</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<!-- 用户访问日志输出 -->
<appender name="sys-user" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.path}/sys-user.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 按天回滚 daily -->
<fileNamePattern>${log.path}/sys-user.%d{yyyy-MM-dd}.log</fileNamePattern>
<!-- 日志最大的历史 60天 -->
<maxHistory>60</maxHistory>
</rollingPolicy>
<encoder>
<pattern>${log.pattern}</pattern>
</encoder>
</appender>
<!-- 显示形成的sql、使用的参数、结果集 -->
<!--
<logger name="java.sql" level="debug" />
<logger name="org.springframework.jdbc" level="debug" />
-->
<logger name="com.qurong" level="info" />
<root level="info">
<appender-ref ref="console" />
</root>
<!--系统操作日志-->
<root level="info">
<appender-ref ref="file_info" />
<appender-ref ref="file_error" />
</root>
<!--系统用户操作日志-->
<logger name="sys-user" level="info">
<appender-ref ref="sys-user"/>
</logger>
</configuration>
\ No newline at end of file \ No newline at end of file
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.glsx.usercenter.mapper.TestMapper" >
<resultMap id="baseUserResultMap" type="com.glsx.usercenter.pojo.Test" >
<id column="id" property="id"/>
<result column="username" property="username"/>
</resultMap>
<select id="get" parameterType="com.glsx.usercenter.pojo.Test" resultMap="baseUserResultMap">
select
u.id, u.username
from sys_user u
where id = #{id}
</select>
<select id="list" resultMap="baseUserResultMap">
select
u.id, u.username
from sys_user u
</select>
</mapper>
\ No newline at end of file \ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?> <?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">
<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">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>com.glsx</groupId> <groupId>com.glsx</groupId>
...@@ -18,7 +16,11 @@ ...@@ -18,7 +16,11 @@
<module>car-service-manager</module> <module>car-service-manager</module>
<module>car-service-common</module> <module>car-service-common</module>
<module>car-service-generator</module> <module>car-service-generator</module>
</modules> <module>car-service-usercenter</module>
<module>car-service-ordercenter</module>
<module>car-service-publicservice</module>
<module>car-service-task</module>
</modules>
<properties> <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
...@@ -35,7 +37,7 @@ ...@@ -35,7 +37,7 @@
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId> <artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.6.RELEASE</version> <version>2.0.6.RELEASE</version>
<relativePath /> <!-- lookup parent from repository --> <relativePath/> <!-- lookup parent from repository -->
</parent> </parent>
<dependencyManagement> <dependencyManagement>
<dependencies> <dependencies>
...@@ -82,7 +84,7 @@ ...@@ -82,7 +84,7 @@
<version>${druid.version}</version> <version>${druid.version}</version>
</dependency> </dependency>
<!-- 日志工具类 --> <!-- 日志工具? -->
<dependency> <dependency>
<groupId>org.slf4j</groupId> <groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId> <artifactId>slf4j-api</artifactId>
...@@ -103,4 +105,4 @@ ...@@ -103,4 +105,4 @@
</plugins> </plugins>
</pluginManagement> </pluginManagement>
</build> </build>
</project> </project>
\ No newline at end of file \ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!