http://localhost:8001/sender?count=10浏览器的请求网址是这个
一,数据源配置
1.1,pom.xml配置
1 <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"> 2 <modelVersion>4.0.0</modelVersion> 3 <groupId>bhz.uts</groupId> 4 <artifactId>uts-sender</artifactId> 5 <version>0.0.1-SNAPSHOT</version> 6 7 <parent> 8 <groupId>org.springframework.boot</groupId> 9 <artifactId>spring-boot-starter-parent</artifactId> 10 <version>1.5.6.RELEASE</version> 11 <relativePath/> <!-- lookup parent from repository --> 12 </parent> 13 14 <properties> 15 <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 16 <java.version>1.8</java.version> 17 <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 18 <java.version>1.8</java.version> 19 <commons-fileupload.version>1.2.2</commons-fileupload.version> 20 <commons-lang3.version>3.3.1</commons-lang3.version> 21 <commons-io.version>2.4</commons-io.version> 22 <commons-collections.version>3.2.2</commons-collections.version> 23 <fastjson.version>1.1.26</fastjson.version> 24 <mybatis.version>3.4.1</mybatis.version> 25 <mybatis-spring.version>1.3.0</mybatis-spring.version> 26 <druid.version>1.0.24</druid.version> 27 <activiti.version>5.21.0</activiti.version> 28 <cxf.version>3.0.0</cxf.version> 29 <cxf-rt.version>3.1.6</cxf-rt.version> 30 <oracle.version>7</oracle.version> 31 <fasterxml.uuid.version>3.1.4</fasterxml.uuid.version> 32 <github.miemiedev.version>1.2.17</github.miemiedev.version> 33 <common.codec.version>1.10</common.codec.version> 34 <servlet-api.version>3.1.0</servlet-api.version> 35 <kaptcha.version>2.3.2</kaptcha.version> 36 <org.codehaus.jackson.version>1.9.13</org.codehaus.jackson.version> 37 <poi-ooxml.version>3.9</poi-ooxml.version> 38 <commons-beanutils.version>1.9.3</commons-beanutils.version> 39 <pinyin4j.version>2.5.1</pinyin4j.version> 40 </properties> 41 42 <dependencies> 43 <!-- 添加SpringMvc、Web[TOMCAT] jar provided排除tomcat, 使用独立容器运行(非内嵌,当) --> 44 <dependency> 45 <groupId>org.springframework.boot</groupId> 46 <artifactId>spring-boot-starter-web</artifactId> 47 </dependency> 48 <dependency> 49 <groupId>org.springframework.boot</groupId> 50 <artifactId>spring-boot-starter-test</artifactId> 51 <scope>test</scope> 52 </dependency> 53 <dependency> 54 <groupId>org.springframework.boot</groupId> 55 <artifactId>spring-boot-starter-aop</artifactId> 56 </dependency> 57 <dependency> 58 <groupId>org.springframework.boot</groupId> 59 <artifactId>spring-boot-autoconfigure</artifactId> 60 </dependency> 61 <dependency> 62 <groupId>commons-fileupload</groupId> 63 <artifactId>commons-fileupload</artifactId> 64 <version>${commons-fileupload.version}</version> 65 </dependency> 66 <dependency> 67 <groupId>org.apache.commons</groupId> 68 <artifactId>commons-lang3</artifactId> 69 <version>${commons-lang3.version}</version> 70 </dependency> 71 <dependency> 72 <groupId>commons-io</groupId> 73 <artifactId>commons-io</artifactId> 74 <version>${commons-io.version}</version> 75 </dependency> 76 <dependency> 77 <groupId>commons-collections</groupId> 78 <artifactId>commons-collections</artifactId> 79 <version>${commons-collections.version}</version> 80 </dependency> 81 <dependency> 82 <groupId>commons-codec</groupId> 83 <artifactId>commons-codec</artifactId> 84 <version>${common.codec.version}</version> 85 </dependency> 86 <dependency> 87 <groupId>commons-beanutils</groupId> 88 <artifactId>commons-beanutils</artifactId> 89 <version>${commons-beanutils.version}</version> 90 </dependency> 91 <dependency> 92 <groupId>com.alibaba</groupId> 93 <artifactId>fastjson</artifactId> 94 <version>${fastjson.version}</version> 95 </dependency> 96 <!--对json格式的支持 --> 97 <dependency> 98 <groupId>org.codehaus.jackson</groupId> 99 <artifactId>jackson-mapper-asl</artifactId> 100 <version>${org.codehaus.jackson.version}</version> 101 </dependency> 102 <dependency> 103 <groupId>com.fasterxml.jackson.core</groupId> 104 <artifactId>jackson-databind</artifactId> 105 </dependency> 106 <dependency> 107 <groupId>com.fasterxml.uuid</groupId> 108 <artifactId>java-uuid-generator</artifactId> 109 <version>${fasterxml.uuid.version}</version> 110 </dependency> 111 <!-- 添加JDBC jar --> 112 <dependency> 113 <groupId>org.springframework.boot</groupId> 114 <artifactId>spring-boot-starter-jdbc</artifactId> 115 </dependency> 116 <dependency> 117 <groupId>org.mybatis.spring.boot</groupId> 118 <artifactId>mybatis-spring-boot-starter</artifactId> 119 <version>1.1.1</version> 120 </dependency> 121 <dependency> 122 <groupId>tk.mybatis</groupId> 123 <artifactId>mapper-spring-boot-starter</artifactId> 124 <version>1.1.0</version> 125 </dependency> 126 <dependency> 127 <groupId>com.alibaba</groupId> 128 <artifactId>druid</artifactId> 129 <version>${druid.version}</version> 130 </dependency> 131 <dependency> 132 <groupId>mysql</groupId> 133 <artifactId>mysql-connector-java</artifactId> 134 </dependency> 135 <dependency> 136 <groupId>com.github.pagehelper</groupId> 137 <artifactId>pagehelper-spring-boot-starter</artifactId> 138 <version>1.1.0</version> 139 <exclusions> 140 <exclusion> 141 <artifactId>mybatis-spring-boot-starter</artifactId> 142 <groupId>org.mybatis.spring.boot</groupId> 143 </exclusion> 144 </exclusions> 145 </dependency> 146 <!-- netty --> 147 <dependency> 148 <groupId>io.netty</groupId> 149 <artifactId>netty-all</artifactId> 150 <version>4.1.12.Final</version> 151 </dependency> 152 <!-- 序列化框架marshalling --> 153 <dependency> 154 <groupId>org.jboss.marshalling</groupId> 155 <artifactId>jboss-marshalling</artifactId> 156 <version>1.3.0.CR9</version> 157 </dependency> 158 <dependency> 159 <groupId>org.jboss.marshalling</groupId> 160 <artifactId>jboss-marshalling-serial</artifactId> 161 <version>1.3.0.CR9</version> 162 </dependency> 163 <!-- netty end --> 164 </dependencies> 165 166 <build> 167 <finalName>uts-sender</finalName> 168 <!-- 打包时包含properties、xml --> 169 <resources> 170 <resource> 171 <directory>src/main/java</directory> 172 <includes> 173 <include>**/*.properties</include> 174 <include>**/*.xml</include> 175 </includes> 176 <!-- 是否替换资源中的属性--> 177 <filtering>true</filtering> 178 </resource> 179 <resource> 180 <directory>src/main/resources</directory> 181 </resource> 182 </resources> 183 <plugins> 184 <plugin> 185 <groupId>org.apache.maven.plugins</groupId> 186 <artifactId>maven-war-plugin</artifactId> 187 </plugin> 188 <!-- 解解决maven update project 后版本降低为1.5的bug --> 189 <plugin> 190 <groupId>org.apache.maven.plugins</groupId> 191 <artifactId>maven-compiler-plugin</artifactId> 192 <configuration> 193 <source>1.8</source> 194 <target>1.8</target> 195 </configuration> 196 </plugin> 197 <!-- 单元测试 --> 198 <plugin> 199 <groupId>org.apache.maven.plugins</groupId> 200 <artifactId>maven-surefire-plugin</artifactId> 201 <configuration> 202 <skip>true</skip> 203 <includes> 204 <include>**/*Test*.java</include> 205 </includes> 206 <testFailureIgnore>true</testFailureIgnore> 207 </configuration> 208 </plugin> 209 <plugin> 210 <groupId>org.apache.maven.plugins</groupId> 211 <artifactId>maven-source-plugin</artifactId> 212 <executions> 213 <!-- 绑定到特定的生命周期之后,运行maven-source-pluin 运行目标为jar-no-fork --> 214 <execution> 215 <phase>package</phase> 216 <goals> 217 <goal>jar-no-fork</goal> 218 </goals> 219 </execution> 220 </executions> 221 </plugin> 222 </plugins> 223 </build> 224 225 </project>
1.2,application.yml配置
1 server: 2 context-path: / 3 port: 8001 4 5 6 transfer: 7 host: 127.0.0.1 8 port: 8765 9 10 ## Spring配置: 11 spring: 12 http: 13 encoding: 14 charset: UTF-8 15 jackson: 16 date-format: yyyy-MM-dd HH:mm:ss 17 time-zone: GMT+8 18 default-property-inclusion: NON_NULL 19 ##DATASOURCE CONFIGURATION -- see druid.yml 20 datasource: 21 type: com.alibaba.druid.pool.DruidDataSource 22 url: jdbc:mysql://localhost:3306/uts-sender?characterEncoding=UTF-8&autoReconnect=true&zeroDateTimeBehavior=convertToNull&useUnicode=true 23 driver-class-name: com.mysql.jdbc.Driver 24 username: root 25 password: root 26 27 28 mybatis: 29 type-aliases-package: bhz.uts 30 mapper-locations: classpath:bhz/uts/mapping/*.xml 31 32 logging: 33 level: 34 tk.mybatis: TRACE 35 36 37 pagehelper: 38 helperDialect: mysql 39 reasonable: true 40 supportMethodsArguments: true 41 params: count=countSql 42 43 44 45
druid.properties
1 ##下面为连接池的补充设置,应用到上面所有数据源中 2 #初始化大小,最小,最大 3 druid.initialSize=50 4 druid.minIdle=10 5 druid.maxIdle=10 6 druid.maxActive=500 7 #配置获取连接等待超时的时间 8 druid.maxWait=60000 9 #配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒 10 druid.timeBetweenEvictionRunsMillis=60000 11 #配置一个连接在池中最小生存的时间,单位是毫秒 12 druid.minEvictableIdleTimeMillis=300000 13 druid.validationQuery=SELECT 1 FROM DUAL 14 druid.testWhileIdle=true 15 druid.testOnBorrow=false 16 druid.testOnReturn=false 17 #打开PSCache,并且指定每个连接上PSCache的大小 18 druid.poolPreparedStatements=true 19 druid.maxPoolPreparedStatementPerConnectionSize=20 20 #配置监控统计拦截的filters,去掉后监控界面sql无法统计,'wall'用于防火墙 21 druid.filters=stat,wall,log4j 22 #通过connectProperties属性来打开mergeSql功能;慢SQL记录 23 druid.connectionProperties=druid.stat.mergeSql=true;druid.stat.slowSqlMillis=5000 24 #合并多个DruidDataSource的监控数据 25 druid.useGlobalDataSourceStat=true
1.3,数据库sql语句
1 /*==============================================================*/ 2 /* DBMS name: MySQL 5.0 */ 3 /* Created on: 2017/9/1 21:40:47 */ 4 /*==============================================================*/ 5 6 7 drop table if exists TRADE_DETAIL; 8 9 /*==============================================================*/ 10 /* Table: TRADE_DETAIL */ 11 /*==============================================================*/ 12 create table TRADE_DETAIL 13 ( 14 ID varchar(128) not null, 15 SERIALNO varchar(128) not null, 16 TRADE_DATE timestamp not null, 17 DEDBIT_AMOUNT numeric(20,2) not null, 18 CREDIT_AMOUNT numeric(20,2) not null, 19 BUSINESS_TYPE varchar(40) not null, 20 BALANCE numeric(20,2) not null, 21 OPP_ACCOUNT_NAME varchar(40) not null, 22 OPP_ACCOUNT_NO varchar(40) not null, 23 ACCOUNT_NAME varchar(40) not null, 24 ACCOUNT_NO varchar(40) not null, 25 DIGEST varchar(400), 26 STATUS varchar(1) not null, 27 CREATE_BY varchar(40) not null, 28 CREATE_TIME timestamp not null, 29 UPDATE_BY varchar(40) not null, 30 UPDATE_TIME timestamp not null, 31 primary key (ID) 32 );
1.4,BaseMapper.java(基础扫描类)
1 package bhz.uts.config.database; 2 3 4 import tk.mybatis.mapper.common.Mapper; 5 import tk.mybatis.mapper.common.MySqlMapper; 6 /** 7 * <B>系统名称:</B><BR> 8 * <B>模块名称:</B>base-sys<BR> 9 * <B>中文类名:</B>BaseMapper<BR> 10 * <B>概要说明:</B>基础数据库服务<BR> 11 * @author bhz 12 * @since 2017年2月8日 下午2:42:49 13 */ 14 public interface BaseMapper<T> extends Mapper<T>, MySqlMapper<T> { 15 16 }
1.5,DruidDataSourceSettings.java(数据源注入类,这个类只负责把配置文件中的数据源的东西加载到相应的属性中来)
1 package bhz.uts.config.database; 2 3 import org.springframework.beans.factory.annotation.Value; 4 import org.springframework.boot.context.properties.ConfigurationProperties; 5 import org.springframework.context.annotation.Bean; 6 import org.springframework.context.annotation.PropertySource; 7 import org.springframework.context.support.PropertySourcesPlaceholderConfigurer; 8 import org.springframework.stereotype.Component; 9 10 @Component 11 @ConfigurationProperties(prefix="spring.datasource") 12 @PropertySource("classpath:druid.properties") 13 public class DruidDataSourceSettings { 14 15 private String driverClassName; 16 private String url; 17 private String username; 18 private String password; 19 20 @Value("${druid.initialSize}") 21 private int initialSize; 22 23 @Value("${druid.minIdle}") 24 private int minIdle; 25 26 @Value("${druid.maxIdle}") 27 private int maxIdle; 28 29 @Value("${druid.maxActive}") 30 private int maxActive; 31 32 @Value("${druid.timeBetweenEvictionRunsMillis}") 33 private long timeBetweenEvictionRunsMillis; 34 35 @Value("${druid.minEvictableIdleTimeMillis}") 36 private long minEvictableIdleTimeMillis; 37 38 @Value("${druid.validationQuery}") 39 private String validationQuery; 40 41 @Value("${druid.testWhileIdle}") 42 private boolean testWhileIdle; 43 44 @Value("${druid.testOnBorrow}") 45 private boolean testOnBorrow; 46 47 @Value("${druid.testOnReturn}") 48 private boolean testOnReturn; 49 50 @Value("${druid.poolPreparedStatements}") 51 private boolean poolPreparedStatements; 52 53 @Value("${druid.maxPoolPreparedStatementPerConnectionSize}") 54 private int maxPoolPreparedStatementPerConnectionSize; 55 56 @Value("${druid.filters}") 57 private String filters; 58 59 @Value("${druid.connectionProperties}") 60 private String connectionProperties; 61 62 @Bean 63 public static PropertySourcesPlaceholderConfigurer properdtyConfigure(){ 64 return new PropertySourcesPlaceholderConfigurer(); 65 } 66 67 public String getDriverClassName() { 68 return driverClassName; 69 } 70 public void setDriverClassName(String driverClassName) { 71 this.driverClassName = driverClassName; 72 } 73 public String getUrl() { 74 return url; 75 } 76 public void setUrl(String url) { 77 this.url = url; 78 } 79 public String getUsername() { 80 return username; 81 } 82 public void setUsername(String username) { 83 this.username = username; 84 } 85 public String getPassword() { 86 return password; 87 } 88 public void setPassword(String password) { 89 this.password = password; 90 } 91 public int getInitialSize() { 92 return initialSize; 93 } 94 public void setInitialSize(int initialSize) { 95 this.initialSize = initialSize; 96 } 97 public int getMinIdle() { 98 return minIdle; 99 } 100 public void setMinIdle(int minIdle) { 101 this.minIdle = minIdle; 102 } 103 public int getMaxIdle() { 104 return maxIdle; 105 } 106 public void setMaxIdle(int maxIdle) { 107 this.maxIdle = maxIdle; 108 } 109 public int getMaxActive() { 110 return maxActive; 111 } 112 public void setMaxActive(int maxActive) { 113 this.maxActive = maxActive; 114 } 115 public long getTimeBetweenEvictionRunsMillis() { 116 return timeBetweenEvictionRunsMillis; 117 } 118 public void setTimeBetweenEvictionRunsMillis(long timeBetweenEvictionRunsMillis) { 119 this.timeBetweenEvictionRunsMillis = timeBetweenEvictionRunsMillis; 120 } 121 public long getMinEvictableIdleTimeMillis() { 122 return minEvictableIdleTimeMillis; 123 } 124 public void setMinEvictableIdleTimeMillis(long minEvictableIdleTimeMillis) { 125 this.minEvictableIdleTimeMillis = minEvictableIdleTimeMillis; 126 } 127 public String getValidationQuery() { 128 return validationQuery; 129 } 130 public void setValidationQuery(String validationQuery) { 131 this.validationQuery = validationQuery; 132 } 133 public boolean isTestWhileIdle() { 134 return testWhileIdle; 135 } 136 public void setTestWhileIdle(boolean testWhileIdle) { 137 this.testWhileIdle = testWhileIdle; 138 } 139 public boolean isTestOnBorrow() { 140 return testOnBorrow; 141 } 142 public void setTestOnBorrow(boolean testOnBorrow) { 143 this.testOnBorrow = testOnBorrow; 144 } 145 public boolean isTestOnReturn() { 146 return testOnReturn; 147 } 148 public void setTestOnReturn(boolean testOnReturn) { 149 this.testOnReturn = testOnReturn; 150 } 151 public boolean isPoolPreparedStatements() { 152 return poolPreparedStatements; 153 } 154 public void setPoolPreparedStatements(boolean poolPreparedStatements) { 155 this.poolPreparedStatements = poolPreparedStatements; 156 } 157 public int getMaxPoolPreparedStatementPerConnectionSize() { 158 return maxPoolPreparedStatementPerConnectionSize; 159 } 160 public void setMaxPoolPreparedStatementPerConnectionSize( 161 int maxPoolPreparedStatementPerConnectionSize) { 162 this.maxPoolPreparedStatementPerConnectionSize = maxPoolPreparedStatementPerConnectionSize; 163 } 164 public String getFilters() { 165 return filters; 166 } 167 public void setFilters(String filters) { 168 this.filters = filters; 169 } 170 public String getConnectionProperties() { 171 return connectionProperties; 172 } 173 public void setConnectionProperties(String connectionProperties) { 174 this.connectionProperties = connectionProperties; 175 } 176 177 }
1.6,MybatisDataSourceConfig.java(注入工厂类)
1 /** 2 * Copyright 2017 JINZAY All Rights Reserved. 3 */ 4 package bhz.uts.config.database; 5 6 import javax.sql.DataSource; 7 8 import org.apache.ibatis.session.SqlSessionFactory; 9 import org.mybatis.spring.SqlSessionFactoryBean; 10 import org.mybatis.spring.SqlSessionTemplate; 11 import org.springframework.beans.factory.annotation.Autowired; 12 import org.springframework.context.annotation.Bean; 13 import org.springframework.context.annotation.Configuration; 14 import org.springframework.core.io.support.PathMatchingResourcePatternResolver; 15 import org.springframework.core.io.support.ResourcePatternResolver; 16 17 @Configuration 18 public class MybatisDataSourceConfig { 19 20 @Autowired 21 private DataSource dataSource; 22 23 @Bean(name="sqlSessionFactory") 24 public SqlSessionFactory sqlSessionFactoryBean() { 25 SqlSessionFactoryBean bean = new SqlSessionFactoryBean(); 26 bean.setDataSource(dataSource); 27 // 添加XML目录 28 ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver(); 29 try { 30 bean.setMapperLocations(resolver.getResources("classpath:bhz/uts/mapping/*.xml")); 31 SqlSessionFactory sqlSessionFactory = bean.getObject(); 32 sqlSessionFactory.getConfiguration().setCacheEnabled(Boolean.TRUE); 33 34 return sqlSessionFactory; 35 } catch (Exception e) { 36 throw new RuntimeException(e); 37 } 38 } 39 40 @Bean 41 public SqlSessionTemplate sqlSessionTemplate(SqlSessionFactory sqlSessionFactory) { 42 return new SqlSessionTemplate(sqlSessionFactory); 43 } 44 45 }
1.7,MybatisMapperScanerConfig.java(扫描数据源类)
1 package bhz.uts.config.database; 2 3 import org.mybatis.spring.mapper.MapperScannerConfigurer; 4 import org.springframework.boot.autoconfigure.AutoConfigureAfter; 5 import org.springframework.context.annotation.Bean; 6 import org.springframework.context.annotation.Configuration; 7 8 @Configuration 9 @AutoConfigureAfter(MybatisDataSourceConfig.class) 10 public class MybatisMapperScanerConfig { 11 12 @Bean 13 public MapperScannerConfigurer mapperScannerConfigurer() { 14 MapperScannerConfigurer mapperScannerConfigurer = new MapperScannerConfigurer(); 15 mapperScannerConfigurer.setSqlSessionFactoryBeanName("sqlSessionFactory"); 16 mapperScannerConfigurer.setBasePackage("bhz.uts.mapper"); 17 return mapperScannerConfigurer; 18 } 19 20 }
1.8,封装数据源类(这个类负责从容器中来取到数据并设置到dataSource对象中来)
1 package bhz.uts.config.database; 2 3 import java.sql.SQLException; 4 5 import javax.sql.DataSource; 6 7 import org.slf4j.Logger; 8 import org.slf4j.LoggerFactory; 9 import org.springframework.beans.factory.annotation.Autowired; 10 import org.springframework.boot.web.servlet.FilterRegistrationBean; 11 import org.springframework.boot.web.servlet.ServletRegistrationBean; 12 import org.springframework.context.annotation.Bean; 13 import org.springframework.context.annotation.Configuration; 14 import org.springframework.context.support.PropertySourcesPlaceholderConfigurer; 15 import org.springframework.jdbc.datasource.DataSourceTransactionManager; 16 import org.springframework.transaction.PlatformTransactionManager; 17 import org.springframework.transaction.annotation.EnableTransactionManagement; 18 19 import com.alibaba.druid.pool.DruidDataSource; 20 import com.alibaba.druid.support.http.StatViewServlet; 21 import com.alibaba.druid.support.http.WebStatFilter; 22 23 @Configuration 24 @EnableTransactionManagement 25 public class DruidDataSourceConfig { 26 27 private static Logger logger = LoggerFactory.getLogger(DruidDataSourceConfig.class); 28 29 @Autowired 30 private DruidDataSourceSettings druidSettings; 31 32 public static String DRIVER_CLASSNAME ; 33 34 @Bean 35 public static PropertySourcesPlaceholderConfigurer propertyConfigure(){ 36 return new PropertySourcesPlaceholderConfigurer(); 37 } 38 //扫描类 39 @Bean 40 public ServletRegistrationBean druidServlet() { 41 42 ServletRegistrationBean reg = new ServletRegistrationBean(); 43 reg.setServlet(new StatViewServlet()); 44 // reg.setAsyncSupported(true); 45 reg.addUrlMappings("/druid/*"); 46 reg.addInitParameter("allow", "127.0.0.1"); 47 // reg.addInitParameter("deny","/deny"); 48 reg.addInitParameter("loginUsername", "bhz"); 49 reg.addInitParameter("loginPassword", "bhz"); 50 logger.info(" druid console manager init : {} ", reg); 51 return reg; 52 } 53 //扫描类 54 @Bean 55 public FilterRegistrationBean filterRegistrationBean() { 56 FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean(); 57 filterRegistrationBean.setFilter(new WebStatFilter()); 58 filterRegistrationBean.addUrlPatterns("/*"); 59 filterRegistrationBean.addInitParameter("exclusions", "*.js,*.gif,*.jpg,*.png,*.css,*.ico, /druid/*"); 60 logger.info(" druid filter register : {} ", filterRegistrationBean); 61 return filterRegistrationBean; 62 } 63 64 @Bean 65 public DataSource dataSource() throws SQLException { 66 DruidDataSource ds = new DruidDataSource(); 67 ds.setDriverClassName(druidSettings.getDriverClassName()); 68 DRIVER_CLASSNAME = druidSettings.getDriverClassName(); 69 ds.setUrl(druidSettings.getUrl()); 70 ds.setUsername(druidSettings.getUsername()); 71 ds.setPassword(druidSettings.getPassword()); 72 ds.setInitialSize(druidSettings.getInitialSize()); 73 ds.setMinIdle(druidSettings.getMinIdle()); 74 ds.setMaxIdle(druidSettings.getMaxIdle()); 75 ds.setMaxActive(druidSettings.getMaxActive()); 76 ds.setTimeBetweenEvictionRunsMillis(druidSettings.getTimeBetweenEvictionRunsMillis()); 77 ds.setMinEvictableIdleTimeMillis(druidSettings.getMinEvictableIdleTimeMillis()); 78 ds.setValidationQuery(druidSettings.getValidationQuery()); 79 ds.setTestWhileIdle(druidSettings.isTestWhileIdle()); 80 ds.setTestOnBorrow(druidSettings.isTestOnBorrow()); 81 ds.setTestOnReturn(druidSettings.isTestOnReturn()); 82 ds.setPoolPreparedStatements(druidSettings.isPoolPreparedStatements()); 83 ds.setMaxPoolPreparedStatementPerConnectionSize(druidSettings.getMaxPoolPreparedStatementPerConnectionSize()); 84 ds.setFilters(druidSettings.getFilters()); 85 ds.setConnectionProperties(druidSettings.getConnectionProperties()); 86 87 //proxyFilters ===> 有问题 88 // WallFilter wallFilter = new WallFilter(); 89 // WallConfig wallConfig = new WallConfig(); 90 // wallConfig.setMultiStatementAllow(true); 91 // wallFilter.setConfig(wallConfig); 92 // List<Filter> wallFilterList = new ArrayList<Filter>(); 93 // wallFilterList.add(wallFilter); 94 // ds.setProxyFilters(wallFilterList); 95 logger.info(" druid datasource config : {} ", ds); 96 return ds; 97 } 98 //事务方法 99 @Bean 100 public PlatformTransactionManager transactionManager() throws Exception { 101 DataSourceTransactionManager txManager = new DataSourceTransactionManager(); 102 txManager.setDataSource(dataSource()); 103 return txManager; 104 } 105 106 }
二,任务时间控制类(在本项目中没有用到)
2.1,TaskSchedulerConfig.java
1 package bhz.uts.config.scheduler; 2 3 import java.util.concurrent.Executor; 4 import java.util.concurrent.Executors; 5 6 import org.springframework.context.annotation.Bean; 7 import org.springframework.context.annotation.Configuration; 8 import org.springframework.scheduling.annotation.EnableScheduling; 9 import org.springframework.scheduling.annotation.SchedulingConfigurer; 10 import org.springframework.scheduling.config.ScheduledTaskRegistrar; 11 12 @Configuration 13 @EnableScheduling 14 public class TaskSchedulerConfig implements SchedulingConfigurer { 15 16 @Override 17 public void configureTasks(ScheduledTaskRegistrar scheduledTaskRegistrar) { 18 scheduledTaskRegistrar.setScheduler(taskScheduler()); 19 } 20 21 @Bean(destroyMethod="shutdown") 22 public Executor taskScheduler(){ 23 return Executors.newScheduledThreadPool(100); 24 } 25 26 }
三,实体类
3.1,BaseEntity.java
1 package bhz.uts.entity; 2 3 public class BaseEntity { 4 5 private String id; 6 7 public String getId() { 8 return id; 9 } 10 11 public void setId(String id) { 12 this.id = id; 13 } 14 15 16 }
3.2,TradeDetail.java
1 package bhz.uts.entity; 2 3 import java.math.BigDecimal; 4 import java.util.Date; 5 6 public class TradeDetail extends BaseEntity { 7 8 private String serialno; 9 10 private Date tradeDate; 11 12 private BigDecimal dedbitAmount; 13 14 private BigDecimal creditAmount; 15 16 private String businessType; 17 18 private BigDecimal balance; 19 20 private String oppAccountName; 21 22 private String oppAccountNo; 23 24 private String accountName; 25 26 private String accountNo; 27 28 private String digest; 29 30 private String status; 31 32 private String createBy; 33 34 private Date createTime; 35 36 private String updateBy; 37 38 private Date updateTime; 39 40 public String getSerialno() { 41 return serialno; 42 } 43 44 public void setSerialno(String serialno) { 45 this.serialno = serialno == null ? null : serialno.trim(); 46 } 47 48 public Date getTradeDate() { 49 return tradeDate; 50 } 51 52 public void setTradeDate(Date tradeDate) { 53 this.tradeDate = tradeDate; 54 } 55 56 public BigDecimal getDedbitAmount() { 57 return dedbitAmount; 58 } 59 60 public void setDedbitAmount(BigDecimal dedbitAmount) { 61 this.dedbitAmount = dedbitAmount; 62 } 63 64 public BigDecimal getCreditAmount() { 65 return creditAmount; 66 } 67 68 public void setCreditAmount(BigDecimal creditAmount) { 69 this.creditAmount = creditAmount; 70 } 71 72 public String getBusinessType() { 73 return businessType; 74 } 75 76 public void setBusinessType(String businessType) { 77 this.businessType = businessType; 78 } 79 80 public BigDecimal getBalance() { 81 return balance; 82 } 83 84 public void setBalance(BigDecimal balance) { 85 this.balance = balance; 86 } 87 88 public String getOppAccountName() { 89 return oppAccountName; 90 } 91 92 public void setOppAccountName(String oppAccountName) { 93 this.oppAccountName = oppAccountName == null ? null : oppAccountName.trim(); 94 } 95 96 public String getOppAccountNo() { 97 return oppAccountNo; 98 } 99 100 public void setOppAccountNo(String oppAccountNo) { 101 this.oppAccountNo = oppAccountNo == null ? null : oppAccountNo.trim(); 102 } 103 104 public String getAccountName() { 105 return accountName; 106 } 107 108 public void setAccountName(String accountName) { 109 this.accountName = accountName; 110 } 111 112 public String getAccountNo() { 113 return accountNo; 114 } 115 116 public void setAccountNo(String accountNo) { 117 this.accountNo = accountNo == null ? null : accountNo.trim(); 118 } 119 120 public String getDigest() { 121 return digest; 122 } 123 124 public void setDigest(String digest) { 125 this.digest = digest == null ? null : digest.trim(); 126 } 127 128 public String getStatus() { 129 return status; 130 } 131 132 public void setStatus(String status) { 133 this.status = status == null ? null : status.trim(); 134 } 135 136 public String getCreateBy() { 137 return createBy; 138 } 139 140 public void setCreateBy(String createBy) { 141 this.createBy = createBy == null ? null : createBy.trim(); 142 } 143 144 public Date getCreateTime() { 145 return createTime; 146 } 147 148 public void setCreateTime(Date createTime) { 149 this.createTime = createTime; 150 } 151 152 public String getUpdateBy() { 153 return updateBy; 154 } 155 156 public void setUpdateBy(String updateBy) { 157 this.updateBy = updateBy == null ? null : updateBy.trim(); 158 } 159 160 public Date getUpdateTime() { 161 return updateTime; 162 } 163 164 public void setUpdateTime(Date updateTime) { 165 this.updateTime = updateTime; 166 } 167 }
四,监听类
4.1,ApplicationFactory.java(容器类)
1 package bhz.uts.listener; 2 3 import org.springframework.beans.BeansException; 4 import org.springframework.context.ApplicationContext; 5 import org.springframework.context.ApplicationContextAware; 6 import org.springframework.stereotype.Component; 7 /** 8 * <B>系统名称:</B><BR> 9 * <B>模块名称:</B><BR> 10 * <B>中文类名:</B>ApplicationFactory<BR> 11 * <B>概要说明:</B><BR> 12 * @author baihezhuo 13 * @since 2017年5月27日 下午4:41:47 14 */ 15 @Component 16 public class ApplicationFactory implements ApplicationContextAware { 17 18 private static ApplicationContext ctx = null; 19 20 @Override 21 public void setApplicationContext(ApplicationContext ctx) throws BeansException { 22 if (ApplicationFactory.ctx == null) { 23 ApplicationFactory.ctx = ctx; 24 } 25 } 26 27 // 获取applicationContext 28 public static ApplicationContext getApplicationContext() { 29 return ctx; 30 } 31 32 // 通过name获取 Bean. 33 public static Object getBean(String name) { 34 return getApplicationContext().getBean(name); 35 } 36 37 // 通过class获取Bean. 38 public static <T> T getBean(Class<T> clazz) { 39 return getApplicationContext().getBean(clazz); 40 } 41 42 // 通过name,以及Clazz返回指定的Bean 43 public static <T> T getBean(String name, Class<T> clazz) { 44 return getApplicationContext().getBean(name, clazz); 45 } 46 47 48 }
4.2,SpringListener.java(监控容器是否加载完的类)
1 package bhz.uts.listener; 2 3 import org.springframework.context.ApplicationListener; 4 import org.springframework.context.event.ContextRefreshedEvent; 5 import org.springframework.stereotype.Component; 6 7 import bhz.uts.netty.NettyClient; 8 9 10 @Component("springListener") 11 public class SpringListener implements ApplicationListener<ContextRefreshedEvent>{ 12 13 @Override 14 public void onApplicationEvent(ContextRefreshedEvent event) { 15 16 if(event.getApplicationContext().getParent() == null){ 17 //需要执行的逻辑代码,当spring容器初始化完成后就会执行该方法。 18 System.out.println("spring 加载完毕.."); 19 try { 20 NettyClient.getInstance().connect(); 21 } catch (Exception e) { 22 e.printStackTrace(); 23 } 24 } 25 26 27 28 } 29 30 31 32 }
spring容器加载好了之后在启动服务器端的链接
五,mapper类
5.1,TradeDetailMapper.java
1 package bhz.uts.mapper; 2 3 import java.util.List; 4 5 import org.apache.ibatis.annotations.Param; 6 7 import bhz.uts.config.database.BaseMapper; 8 import bhz.uts.entity.TradeDetail; 9 10 public interface TradeDetailMapper extends BaseMapper<TradeDetail> { 11 12 int updateStatusById(@Param("id")String id); 13 14 List<TradeDetail> queryByNotSync(); 15 16 }
5.2,TradeDetailMapper.xml
1 <?xml version="1.0" encoding="UTF-8" ?> 2 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > 3 <mapper namespace="bhz.uts.mapper.TradeDetailMapper" > 4 <resultMap id="BaseResultMap" type="bhz.uts.entity.TradeDetail" > 5 <id column="ID" property="id" jdbcType="VARCHAR" /> 6 <result column="SERIALNO" property="serialno" jdbcType="VARCHAR" /> 7 <result column="TRADE_DATE" property="tradeDate" jdbcType="TIMESTAMP" /> 8 <result column="DEDBIT_AMOUNT" property="dedbitAmount" jdbcType="DECIMAL" /> 9 <result column="CREDIT_AMOUNT" property="creditAmount" jdbcType="DECIMAL" /> 10 <result column="BUSINESS_TYPE" property="businessType" jdbcType="VARCHAR" /> 11 <result column="BALANCE" property="balance" jdbcType="DECIMAL" /> 12 <result column="OPP_ACCOUNT_NAME" property="oppAccountName" jdbcType="VARCHAR" /> 13 <result column="OPP_ACCOUNT_NO" property="oppAccountNo" jdbcType="VARCHAR" /> 14 <result column="ACCOUNT_NAME" property="accountName" jdbcType="VARCHAR" /> 15 <result column="ACCOUNT_NO" property="accountNo" jdbcType="VARCHAR" /> 16 <result column="DIGEST" property="digest" jdbcType="VARCHAR" /> 17 <result column="STATUS" property="status" jdbcType="VARCHAR" /> 18 <result column="CREATE_BY" property="createBy" jdbcType="VARCHAR" /> 19 <result column="CREATE_TIME" property="createTime" jdbcType="TIMESTAMP" /> 20 <result column="UPDATE_BY" property="updateBy" jdbcType="VARCHAR" /> 21 <result column="UPDATE_TIME" property="updateTime" jdbcType="TIMESTAMP" /> 22 </resultMap> 23 <sql id="Base_Column_List" > 24 ID, SERIALNO, TRADE_DATE, DEDBIT_AMOUNT, CREDIT_AMOUNT, BUSINESS_TYPE, BALANCE, OPP_ACCOUNT_NAME, 25 OPP_ACCOUNT_NO, ACCOUNT_NAME, ACCOUNT_NO, DIGEST, STATUS, CREATE_BY, CREATE_TIME, 26 UPDATE_BY, UPDATE_TIME 27 </sql> 28 29 <update id="updateStatusById" > 30 UPDATE TRADE_DETAIL SET STATUS = 1 WHERE ID = #{id,jdbcType=VARCHAR} 31 </update> 32 33 <select id="queryByNotSync" resultMap="BaseResultMap" > 34 SELECT * FROM TRADE_DETAIL WHERE STATUS = 0 35 </select> 36 37 </mapper>
六,service类
6.1,TradeDetailService.java
1 package bhz.uts.service; 2 3 import org.springframework.beans.factory.annotation.Autowired; 4 import org.springframework.stereotype.Service; 5 import org.springframework.transaction.annotation.Transactional; 6 7 import com.alibaba.fastjson.JSONObject; 8 9 import bhz.uts.entity.TradeDetail; 10 import bhz.uts.mapper.TradeDetailMapper; 11 import bhz.uts.netty.NettyClient; 12 import bhz.uts.protocol.Req; 13 import bhz.uts.utils.Const; 14 import io.netty.channel.ChannelFuture; 15 16 @Service 17 public class TradeDetailService { 18 19 20 @Autowired 21 private TradeDetailMapper tradeDetailMapper; 22 23 @Transactional 24 public void sender(TradeDetail td) { 25 26 //1 insert 27 tradeDetailMapper.insert(td); 28 //2 transfer 29 //3,从clent角度来看,3.1,先把数据设置到req对象中来,假如有信息返回的话在去执行channelfuture里面的内容 30 ChannelFuture cf = NettyClient.getInstance().getChannelFuture(); 31 Req req = new Req(); 32 req.setId(td.getId()); 33 req.setReqeustMessage(JSONObject.toJSONString(td)); 34 req.setTag(Const.TRADE_DETAIL); 35 req.setType(Const.SAVE); 36 cf.channel().writeAndFlush(req); 37 38 } 39 40 public int updateStatusById(String id) { 41 return tradeDetailMapper.updateStatusById(id); 42 } 43 44 45 }
加红色字体的就是最明显的异步非阻塞的代表,代码走到第30行的时候就会接着往下走,走31行的代码,而这时后开启的另一个线程就会去走第30行里面的数据,按照业务逻辑的话是31-36行和
group = new NioEventLoopGroup();
b = new Bootstrap();
b.group(group)
.channel(NioSocketChannel.class)
.handler(new ChannelInitializer<SocketChannel>() {
@Override
protected void initChannel(SocketChannel sc) throws Exception {
sc.pipeline().addLast(MarshallingCodeCFactory.buildMarshallingDecoder());
sc.pipeline().addLast(MarshallingCodeCFactory.buildMarshallingEncoder());
sc.pipeline().addLast(new NettyClientHandler());
在前面的,只有它先在客户端把信息传递到服务端才会执行
@Override
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
try {
Resp resp = (Resp)msg;
String id = resp.getId();
String tag = resp.getTag();
String type = resp.getType();
String responseCode = resp.getResponseCode();
String responseMessage = resp.getResponseMessage();
这里面的代码的。
6.2,SenderTradeDetailController.java(浏览器调用类)
1 package bhz.uts.service.api; 2 3 import org.springframework.beans.factory.annotation.Autowired; 4 import org.springframework.web.bind.annotation.RequestMapping; 5 import org.springframework.web.bind.annotation.RequestParam; 6 import org.springframework.web.bind.annotation.RestController; 7 8 import bhz.uts.entity.TradeDetail; 9 import bhz.uts.service.TradeDetailService; 10 import bhz.uts.utils.GeneratorDataUtil; 11 12 @RestController 13 public class SenderTradeDetailController { 14 15 @Autowired 16 private TradeDetailService tradeDetailService; 17 18 @RequestMapping("/sender") 19 public void sender(@RequestParam("count") Integer count) throws Exception { 20 21 for(int i =0; i < count ; i ++){ 22 TradeDetail td = GeneratorDataUtil.generator(); 23 ///拿到数据以后, 调用service 24 tradeDetailService.sender(td); 25 } 26 } 27 28 }
http://localhost:8001/sender?count=10浏览器的请求网址是这个
七,编辑码的请求和相应类
7.1,Req.java
1 package bhz.uts.protocol; 2 3 import java.io.Serializable; 4 5 public class Req implements Serializable { 6 7 8 private static final long serialVersionUID = 1L; 9 10 private String id ; //唯一ID 11 private String type ; //操作类型 12 private String tag ; //传输对象的类型::: 13 private String reqeustMessage; //json对象 14 public String getId() { 15 return id; 16 } 17 public void setId(String id) { 18 this.id = id; 19 } 20 public String getType() { 21 return type; 22 } 23 public void setType(String type) { 24 this.type = type; 25 } 26 public String getTag() { 27 return tag; 28 } 29 public void setTag(String tag) { 30 this.tag = tag; 31 } 32 public String getReqeustMessage() { 33 return reqeustMessage; 34 } 35 public void setReqeustMessage(String reqeustMessage) { 36 this.reqeustMessage = reqeustMessage; 37 } 38 39 40 41 42 43 44 45 46 }
7.2,Resp.java
1 package bhz.uts.protocol; 2 3 import java.io.Serializable; 4 5 public class Resp implements Serializable { 6 7 8 private static final long serialVersionUID = 1L; 9 10 private String id; 11 private String type; 12 private String tag; 13 private String responseCode; //响应码:: 14 private String responseMessage; 15 16 17 public String getId() { 18 return id; 19 } 20 public void setId(String id) { 21 this.id = id; 22 } 23 public String getType() { 24 return type; 25 } 26 public void setType(String type) { 27 this.type = type; 28 } 29 public String getTag() { 30 return tag; 31 } 32 public void setTag(String tag) { 33 this.tag = tag; 34 } 35 public String getResponseCode() { 36 return responseCode; 37 } 38 public void setResponseCode(String responseCode) { 39 this.responseCode = responseCode; 40 } 41 public String getResponseMessage() { 42 return responseMessage; 43 } 44 public void setResponseMessage(String responseMessage) { 45 this.responseMessage = responseMessage; 46 } 47 48 49 50 51 }
八,netty的客户端代码
8.1,MarshallingCodeCFactory.java(编解码类)
1 package bhz.uts.netty; 2 3 import io.netty.handler.codec.marshalling.DefaultMarshallerProvider; 4 import io.netty.handler.codec.marshalling.DefaultUnmarshallerProvider; 5 import io.netty.handler.codec.marshalling.MarshallerProvider; 6 import io.netty.handler.codec.marshalling.MarshallingDecoder; 7 import io.netty.handler.codec.marshalling.MarshallingEncoder; 8 import io.netty.handler.codec.marshalling.UnmarshallerProvider; 9 10 import org.jboss.marshalling.MarshallerFactory; 11 import org.jboss.marshalling.Marshalling; 12 import org.jboss.marshalling.MarshallingConfiguration; 13 14 /** 15 * Marshalling工厂 16 * @author(alienware) 17 * @since 2014-12-16 18 */ 19 public final class MarshallingCodeCFactory { 20 21 /** 22 * 创建Jboss Marshalling解码器MarshallingDecoder 23 * @return MarshallingDecoder 24 */ 25 public static MarshallingDecoder buildMarshallingDecoder() { 26 //首先通过Marshalling工具类的精通方法获取Marshalling实例对象 参数serial标识创建的是java序列化工厂对象。 27 final MarshallerFactory marshallerFactory = Marshalling.getProvidedMarshallerFactory("serial"); 28 //创建了MarshallingConfiguration对象,配置了版本号为5 29 final MarshallingConfiguration configuration = new MarshallingConfiguration(); 30 configuration.setVersion(5); 31 //根据marshallerFactory和configuration创建provider 32 UnmarshallerProvider provider = new DefaultUnmarshallerProvider(marshallerFactory, configuration); 33 //构建Netty的MarshallingDecoder对象,俩个参数分别为provider和单个消息序列化后的最大长度 34 MarshallingDecoder decoder = new MarshallingDecoder(provider, 1024 * 1024 * 1); 35 return decoder; 36 } 37 38 /** 39 * 创建Jboss Marshalling编码器MarshallingEncoder 40 * @return MarshallingEncoder 41 */ 42 public static MarshallingEncoder buildMarshallingEncoder() { 43 final MarshallerFactory marshallerFactory = Marshalling.getProvidedMarshallerFactory("serial"); 44 final MarshallingConfiguration configuration = new MarshallingConfiguration(); 45 configuration.setVersion(5); 46 MarshallerProvider provider = new DefaultMarshallerProvider(marshallerFactory, configuration); 47 //构建Netty的MarshallingEncoder对象,MarshallingEncoder用于实现序列化接口的POJO对象序列化为二进制数组 48 MarshallingEncoder encoder = new MarshallingEncoder(provider); 49 return encoder; 50 } 51 }
8.2,NettyClient.java(客户端类)
1 package bhz.uts.netty; 2 3 import io.netty.bootstrap.Bootstrap; 4 import io.netty.channel.ChannelFuture; 5 import io.netty.channel.ChannelInitializer; 6 import io.netty.channel.EventLoopGroup; 7 import io.netty.channel.nio.NioEventLoopGroup; 8 import io.netty.channel.socket.SocketChannel; 9 import io.netty.channel.socket.nio.NioSocketChannel; 10 11 public class NettyClient { 12 13 private static class SingletionHolder { 14 static final NettyClient instance = new NettyClient(); 15 } 16 17 public static NettyClient getInstance(){ 18 return SingletionHolder.instance; 19 } 20 21 private String host = "127.0.0.1"; 22 23 private int port = 8765; 24 25 private EventLoopGroup group; 26 27 private Bootstrap b; 28 29 private ChannelFuture cf; 30 31 private NettyClient(){ 32 group = new NioEventLoopGroup(); 33 b = new Bootstrap(); 34 b.group(group) 35 .channel(NioSocketChannel.class) 36 .handler(new ChannelInitializer<SocketChannel>() { 37 @Override 38 protected void initChannel(SocketChannel sc) throws Exception { 39 sc.pipeline().addLast(MarshallingCodeCFactory.buildMarshallingDecoder()); 40 sc.pipeline().addLast(MarshallingCodeCFactory.buildMarshallingEncoder()); 41 sc.pipeline().addLast(new NettyClientHandler()); 42 } 43 }); 44 } 45 46 public void connect(){ 47 try { 48 this.cf = this.b.connect(host, port).sync(); 49 System.err.println("远程服务器端已经连接.. 可以进行数据通信...."); 50 } catch (InterruptedException e) { 51 e.printStackTrace(); 52 } 53 } 54 55 public void close(){ 56 try { 57 this.cf.channel().closeFuture().sync(); 58 this.group.shutdownGracefully(); 59 } catch (InterruptedException e) { 60 e.printStackTrace(); 61 } 62 } 63 64 public ChannelFuture getChannelFuture(){ 65 if(this.cf == null) { 66 this.connect(); 67 } 68 if(!this.cf.channel().isActive()){ 69 this.connect(); 70 } 71 return this.cf; 72 } 73 74 75 public String getHost() { 76 return host; 77 } 78 79 public void setHost(String host) { 80 this.host = host; 81 } 82 83 public int getPort() { 84 return port; 85 } 86 87 public void setPort(int port) { 88 this.port = port; 89 } 90 91 92 93 94 95 }
8.3,NettyClientHandler.java(实现类)
1 package bhz.uts.netty; 2 3 import bhz.uts.listener.ApplicationFactory; 4 import bhz.uts.protocol.Resp; 5 import bhz.uts.service.TradeDetailService; 6 import bhz.uts.utils.Const; 7 import io.netty.channel.ChannelHandlerContext; 8 import io.netty.channel.ChannelInboundHandlerAdapter; 9 import io.netty.util.ReferenceCountUtil; 10 11 public class NettyClientHandler extends ChannelInboundHandlerAdapter { 12 13 @Override 14 public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception { 15 try { 16 17 Resp resp = (Resp)msg; 18 String id = resp.getId(); 19 String tag = resp.getTag(); 20 String type = resp.getType(); 21 String responseCode = resp.getResponseCode(); 22 String responseMessage = resp.getResponseMessage(); 23 24 if(Const.TRADE_DETAIL.equals(tag)){ 25 TradeDetailService tradeDetailService = (TradeDetailService)ApplicationFactory.getBean("tradeDetailService"); 26 27 if(Const.RESPONSE_CODE_OK.equals(responseCode)){ 28 if(Const.UPDATE.equals(type)) { 29 System.err.println("更新同步标志-----------: id: " + id); 30 tradeDetailService.updateStatusById(id); 31 } 32 } 33 } 34 35 } finally { 36 ReferenceCountUtil.release(msg); 37 } 38 39 } 40 41 42 }
九,工具类
9.1,Const.java(常量类)
1 package bhz.uts.utils;
2
3 public final class Const { 4 5 public static final String TRADE_DETAIL = "trade_detail"; 6 public static final String TRADE_BALANCE = "trade_balance"; 7 8 public static final String QUERY = "query"; 9 public static final String SAVE = "save"; 10 public static final String UPDATE = "update"; 11 public static final String DELETE = "delete"; 12 13 14 public static final String RESPONSE_CODE_OK = "1"; 15 public static final String RESPONSE_CODE_INSERT_ERR = "2"; 16 public static final String RESPONSE_CODE_SERVER_ERR = "3"; 17 18 }
9.2,FastJsonConvertUtil.java(json转化类)
1 package bhz.uts.utils;
2
3 import java.util.ArrayList; 4 import java.util.List; 5 6 import com.alibaba.fastjson.JSON; 7 import com.alibaba.fastjson.JSONObject; 8 import com.alibaba.fastjson.serializer.SerializerFeature; 9 10 /** 11 * <B>系统名称:</B>通用平台<BR> 12 * <B>模块名称:</B>通用平台-公共服务<BR> 13 * <B>中文类名:</B>通用平台-公共服务-FastJsonConvert<BR> 14 * <B>概要说明:</B><BR> 15 * @author bhz 16 * @since 2016年10月10日 上午11:01:52 17 */ 18 public class FastJsonConvertUtil { 19 20 private static final SerializerFeature[] featuresWithNullValue = { SerializerFeature.WriteMapNullValue, SerializerFeature.WriteNullBooleanAsFalse, 21 SerializerFeature.WriteNullListAsEmpty, SerializerFeature.WriteNullNumberAsZero, SerializerFeature.WriteNullStringAsEmpty }; 22 23 /** 24 * <B>方法名称:</B>将JSON字符串转换为实体对象<BR> 25 * <B>概要说明:</B>将JSON字符串转换为实体对象<BR> 26 * @param data JSON字符串 27 * @param clzss 转换对象 28 * @return T 29 */ 30 public static <T> T convertJSONToObject(String data, Class<T> clzss) { 31 try { 32 T t = JSON.parseObject(data, clzss); 33 return t; 34 } catch (Exception e) { 35 e.printStackTrace(); 36 return null; 37 } 38 } 39 40 /** 41 * <B>方法名称:</B>将JSONObject对象转换为实体对象<BR> 42 * <B>概要说明:</B>将JSONObject对象转换为实体对象<BR> 43 * @param data JSONObject对象 44 * @param clzss 转换对象 45 * @return T 46 */ 47 public static <T> T convertJSONToObject(JSONObject data, Class<T> clzss) { 48 try { 49 T t = JSONObject.toJavaObject(data, clzss); 50 return t; 51 } catch (Exception e) { 52 e.printStackTrace(); 53 return null; 54 } 55 } 56 57 /** 58 * <B>方法名称:</B>将JSON字符串数组转为List集合对象<BR> 59 * <B>概要说明:</B>将JSON字符串数组转为List集合对象<BR> 60 * @param data JSON字符串数组 61 * @param clzss 转换对象 62 * @return List<T>集合对象 63 */ 64 public static <T> List<T> convertJSONToArray(String data, Class<T> clzss) { 65 try { 66 List<T> t = JSON.parseArray(data, clzss); 67 return t; 68 } catch (Exception e) { 69 e.printStackTrace(); 70 return null; 71 } 72 } 73 74 /** 75 * <B>方法名称:</B>将List<JSONObject>转为List集合对象<BR> 76 * <B>概要说明:</B>将List<JSONObject>转为List集合对象<BR> 77 * @param data List<JSONObject> 78 * @param clzss 转换对象 79 * @return List<T>集合对象 80 */ 81 public static <T> List<T> convertJSONToArray(List<JSONObject> data, Class<T> clzss) { 82 try { 83 List<T> t = new ArrayList<T>(); 84 for (JSONObject jsonObject : data) { 85 t.add(convertJSONToObject(jsonObject, clzss)); 86 } 87 return t; 88 } catch (Exception e) { 89 e.printStackTrace(); 90 return null; 91 } 92 } 93 94 /** 95 * <B>方法名称:</B>将对象转为JSON字符串<BR> 96 * <B>概要说明:</B>将对象转为JSON字符串<BR> 97 * @param obj 任意对象 98 * @return JSON字符串 99 */ 100 public static String convertObjectToJSON(Object obj) { 101 try { 102 String text = JSON.toJSONString(obj); 103 return text; 104 } catch (Exception e) { 105 e.printStackTrace(); 106 return null; 107 } 108 } 109 110 /** 111 * <B>方法名称:</B>将对象转为JSONObject对象<BR> 112 * <B>概要说明:</B>将对象转为JSONObject对象<BR> 113 * @param obj 任意对象 114 * @return JSONObject对象 115 */ 116 public static JSONObject convertObjectToJSONObject(Object obj){ 117 try { 118 JSONObject jsonObject = (JSONObject) JSONObject.toJSON(obj); 119 return jsonObject; 120 } catch (Exception e) { 121 e.printStackTrace(); 122 return null; 123 } 124 } 125 126 127 /** 128 * <B>方法名称:</B><BR> 129 * <B>概要说明:</B><BR> 130 * @param obj 131 * @return 132 */ 133 public static String convertObjectToJSONWithNullValue(Object obj) { 134 try { 135 String text = JSON.toJSONString(obj, featuresWithNullValue); 136 return text; 137 } catch (Exception e) { 138 e.printStackTrace(); 139 return null; 140 } 141 } 142 143 public static void main(String[] args) { 144 System.err.println(System.getProperties()); 145 } 146 }
9.3,GeneratorDataUtil.java(造数据的类)
1 package bhz.uts.utils;
2
3 import java.math.BigDecimal; 4 import java.text.SimpleDateFormat; 5 import java.util.Date; 6 import java.util.Random; 7 import java.util.UUID; 8 9 import bhz.uts.entity.TradeDetail; 10 11 public class GeneratorDataUtil { 12 13 private static Random random = new Random(); 14 15 //交易时间: 16 private static Date getRandomDate(){ 17 SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); 18 Date d = new Date(117, 19 random.nextInt(7), 20 (int)(Math.random()*28)+1, 21 (int)(Math.random()*23)+1, 22 (int)(Math.random()*59)+1, 23 (int)(Math.random()*59)+1); 24 System.out.println(formatter.format(d)); 25 return d; 26 } 27 28 static Object[] accounts = null; 29 static { 30 Pair p1 = new Pair<String, String>("张三", "30001040191113380583"); 31 Pair p2 = new Pair<String, String>("李四", "40003242903000023274"); 32 Pair p3 = new Pair<String, String>("王五", "50033457780002320965"); 33 Pair p4 = new Pair<String, String>("赵六", "68886000080002320926"); 34 accounts = new Object[]{p1, p2, p3, p4}; 35 } 36 37 static Object[] oppAccounts = null; 38 static { 39 Pair p1 = new Pair<String, String>("小1", "500013334380543599"); 40 Pair p2 = new Pair<String, String>("小2", "498980000566599998"); 41 Pair p3 = new Pair<String, String>("小3", "788876699990005589"); 42 Pair p4 = new Pair<String, String>("小4", "155500006660007779"); 43 Pair p5 = new Pair<String, String>("小5", "344339999333000001"); 44 oppAccounts = new Object[]{p1, p2, p3, p4, p5}; 45 } 46 47 // 48 private static String generateSerialno(Date d){ 49 SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMdd"); 50 StringBuffer key = new StringBuffer(); 51 key.append(formatter.format(d)); 52 String uid = UUID.randomUUID().toString().replaceAll("-", "").toUpperCase(); 53 key.append(uid.substring(12)); 54 return key.toString(); 55 } 56 57 // 58 private static Pair getRandomAccounts(){ 59 return (Pair) accounts[random.nextInt(accounts.length)]; 60 } 61 62 private static Pair getRandomOppAccounts(){ 63 return (Pair) oppAccounts[random.nextInt(oppAccounts.length)]; 64 } 65 66 67 static Object[] digests = null; 68 static { 69 String d1 = "转账"; 70 String d2 = "付款"; 71 String d3 = "百度买单"; 72 String d4 = "美团买单"; 73 String d5 = "淘宝买单"; 74 digests = new Object[]{d1, d2, d3, d4, d5}; 75 } 76 77 private static String getRandomDigest(){ 78 return (String) digests[random.nextInt(digests.length)]; 79 } 80 81 public static void main(String[] args) { 82 System.err.println(getRandomBalance()); 83 } 84 85 private static int getRandomCreditAmount(){ 86 return (int) ((Math.random()*100)+ (Math.random()*300) + (Math.random()*80)); 87 } 88 89 private static int getRandomBalance(){ 90 return (int) ((Math.random()*100000)+ (Math.random()*3000) + (Math.random()*500)); 91 } 92 93 94 public static TradeDetail generator() { 95 TradeDetail td1 = new TradeDetail(); 96 td1.setId(KeyUtil.generatorUUID()); 97 Date tradeDate = getRandomDate(); 98 99 td1.setSerialno(generateSerialno(tradeDate)); 100 td1.setTradeDate(tradeDate); 101 td1.setCreditAmount(new BigDecimal(getRandomCreditAmount())); 102 td1.setDedbitAmount(new BigDecimal(0)); 103 td1.setBusinessType("1"); 104 td1.setBalance(new BigDecimal(getRandomBalance())); 105 106 Pair account = getRandomAccounts(); 107 108 td1.setAccountName((String) account.getObject1()); 109 td1.setAccountNo((String) account.getObject2()); 110 111 112 Pair oppAccount = getRandomOppAccounts(); 113 td1.setOppAccountName((String) oppAccount.getObject1()); 114 td1.setOppAccountNo((String) oppAccount.getObject2()); 115 116 td1.setDigest(getRandomDigest()); 117 td1.setStatus("0"); 118 td1.setCreateBy("system"); 119 td1.setCreateTime(new Date()); 120 td1.setUpdateBy("system"); 121 td1.setUpdateTime(new Date()); 122 return td1; 123 124 } 125 126 }
9.4,GzipUtil.java(压缩解压类)
1 package bhz.uts.utils;
2
3 import java.io.ByteArrayInputStream; 4 import java.io.ByteArrayOutputStream; 5 import java.io.File; 6 import java.io.FileInputStream; 7 import java.io.FileOutputStream; 8 import java.util.zip.GZIPInputStream; 9 import java.util.zip.GZIPOutputStream; 10 11 public class GzipUtil { 12 13 public static byte[] gzip(byte[] data) throws Exception{ 14 ByteArrayOutputStream bos = new ByteArrayOutputStream(); 15 GZIPOutputStream gzip = new GZIPOutputStream(bos); 16 gzip.write(data); 17 gzip.finish(); 18 gzip.close(); 19 byte[] ret = bos.toByteArray(); 20 bos.close(); 21 return ret; 22 } 23 24 public static byte[] ungzip(byte[] data) throws Exception{ 25 ByteArrayInputStream bis = new ByteArrayInputStream(data); 26 GZIPInputStream gzip = new GZIPInputStream(bis); 27 byte[] buf = new byte[1024]; 28 int num = -1; 29 ByteArrayOutputStream bos = new ByteArrayOutputStream(); 30 while((num = gzip.read(buf, 0 , buf.length)) != -1 ){ 31 bos.write(buf, 0, num); 32 } 33 gzip.close(); 34 bis.close(); 35 byte[] ret = bos.toByteArray(); 36 bos.flush(); 37 bos.close(); 38 return ret; 39 } 40 41 public static void main(String[] args) throws Exception{ 42 43 //读取文件 44 String readPath = System.getProperty("user.dir") + File.separatorChar + "sources" + File.separatorChar + "006.jpg"; 45 File file = new File(readPath); 46 FileInputStream in = new FileInputStream(file); 47 byte[] data = new byte[in.available()]; 48 in.read(data); 49 in.close(); 50 51 System.out.println("文件原始大小:" + data.length); 52 //测试压缩 53 54 byte[] ret1 = GzipUtil.gzip(data); 55 System.out.println("压缩之后大小:" + ret1.length); 56 57 byte[] ret2 = GzipUtil.ungzip(ret1); 58 System.out.println("还原之后大小:" + ret2.length); 59 60 //写出文件 61 String writePath = System.getProperty("user.dir") + File.separatorChar + "receive" + File.separatorChar + "006.jpg"; 62 FileOutputStream fos = new FileOutputStream(writePath); 63 fos.write(ret2); 64 fos.close(); 65 66 67 } 68 69 70 71 }
9.5,KeyUtil.java(主键生成策略类)
1 package bhz.uts.utils;
2
3 import java.util.UUID; 4 5 import com.fasterxml.uuid.EthernetAddress; 6 import com.fasterxml.uuid.Generators; 7 import com.fasterxml.uuid.impl.TimeBasedGenerator; 8 9 /** 10 * <B>系统名称:</B>通用平台<BR> 11 * <B>模块名称:</B>通用平台-公共服务<BR> 12 * <B>中文类名:</B>KeyUtils<BR> 13 * <B>概要说明:</B>主键生成策略-工具类<BR> 14 * @author baihezhuo 15 * @since 2017年2月21日 下午1:55:42 16 */ 17 public class KeyUtil { 18 19 /** 20 * <B>方法名称:</B>generatorUUID<BR> 21 * <B>概要说明:</B>主键生成策略<BR> 22 * @author baihezhuo 23 * @since 2017年2月21日 下午2:00:06 24 * @return UUID String 25 */ 26 public static String generatorUUID(){ 27 TimeBasedGenerator timeBasedGenerator = Generators.timeBasedGenerator(EthernetAddress.fromInterface()); 28 return timeBasedGenerator.generate().toString(); 29 } 30 31 32 33 }
9.6,Pair.java(键值对类)
1 package bhz.uts.utils;
2
3 public class Pair<T1, T2> { 4 private T1 object1; 5 private T2 object2; 6 7 public Pair(T1 object1, T2 object2) { 8 this.object1 = object1; 9 this.object2 = object2; 10 } 11 12 public T1 getObject1() { 13 return object1; 14 } 15 16 public void setObject1(T1 object1) { 17 this.object1 = object1; 18 } 19 20 public T2 getObject2() { 21 return object2; 22 } 23 24 public void setObject2(T2 object2) { 25 this.object2 = object2; 26 } 27 }
十,主类
10.1,MainConfig.java(主要扫描类)
1 package bhz.uts; 2 3 import org.mybatis.spring.annotation.MapperScan; 4 import org.springframework.context.annotation.ComponentScan; 5 import org.springframework.context.annotation.Configuration; 6 7 @Configuration 8 @MapperScan(basePackages = "bhz.uts.mapper") 9 @ComponentScan(basePackages = {"bhz.uts.*", "bhz.uts.config.*"}) 10 public class MainConfig { 11 12 }
10.2,UtsSenderApplication.java(springboot的启动类)
1 package bhz.uts; 2 3 import org.springframework.boot.SpringApplication; 4 import org.springframework.boot.autoconfigure.SpringBootApplication; 5 6 @SpringBootApplication 7 public class UtsSenderApplication { 8 9 public static void main(String[] args) { 10 SpringApplication.run(UtsSenderApplication.class, args); 11 } 12 }
控制台:
1 Java HotSpot(TM) 64-Bit Server VM warning: MaxNewSize (524288k) is equal to or greater than the entire heap (524288k). A new generation size of 524224k will be used. 2 3 . ____ _ __ _ _ 4 /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \ 5 ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \ 6 \\/ ___)| |_)| | | | | || (_| | ) ) ) ) 7 ' |____| .__|_| |_|_| |_\__, | / / / / 8 =========|_|==============|___/=/_/_/_/ 9 :: Spring Boot :: (v1.5.6.RELEASE) 10 11 2018-03-21 20:31:27.719 INFO 2180 --- [ main] bhz.uts.UtsSenderApplication : Starting UtsSenderApplication on qingruihappy with PID 2180 (D:\workspace\uts-sender\target\classes started by Administrator in D:\workspace\uts-sender) 12 2018-03-21 20:31:27.731 INFO 2180 --- [ main] bhz.uts.UtsSenderApplication : No active profile set, falling back to default profiles: default 13 2018-03-21 20:31:27.834 INFO 2180 --- [ main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@594001dc: startup date [Wed Mar 21 20:31:27 CST 2018]; root of context hierarchy 14 2018-03-21 20:31:29.885 WARN 2180 --- [ main] o.m.s.mapper.ClassPathMapperScanner : Skipping MapperFactoryBean with name 'tradeDetailMapper' and 'bhz.uts.mapper.TradeDetailMapper' mapperInterface. Bean already defined with the same name! 15 2018-03-21 20:31:29.885 WARN 2180 --- [ main] o.m.s.mapper.ClassPathMapperScanner : No MyBatis mapper was found in '[bhz.uts.mapper]' package. Please check your configuration. 16 2018-03-21 20:31:29.887 WARN 2180 --- [ main] o.s.c.a.ConfigurationClassPostProcessor : Cannot enhance @Configuration bean definition 'mybatisMapperScanerConfig' since its singleton instance has been created too early. The typical cause is a non-static @Bean method with a BeanDefinitionRegistryPostProcessor return type: Consider declaring such methods as 'static'. 17 2018-03-21 20:31:30.295 WARN 2180 --- [ main] figurationPropertiesBindingPostProcessor : Multiple PropertySourcesPlaceholderConfigurer beans registered [propertyConfigure, properdtyConfigure], falling back to Environment 18 2018-03-21 20:31:33.128 INFO 2180 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8001 (http) 19 2018-03-21 20:31:33.176 INFO 2180 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat] 20 2018-03-21 20:31:33.178 INFO 2180 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.5.16 21 2018-03-21 20:31:33.811 INFO 2180 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext 22 2018-03-21 20:31:33.812 INFO 2180 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 5994 ms 23 2018-03-21 20:31:34.079 INFO 2180 --- [ost-startStop-1] b.u.c.database.DruidDataSourceConfig : druid console manager init : org.springframework.boot.web.servlet.ServletRegistrationBean@13084eb3 24 2018-03-21 20:31:34.143 INFO 2180 --- [ost-startStop-1] b.u.c.database.DruidDataSourceConfig : druid filter register : org.springframework.boot.web.servlet.FilterRegistrationBean@4863d07f 25 2018-03-21 20:31:34.941 INFO 2180 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean : Mapping servlet: 'statViewServlet' to [/druid/*] 26 2018-03-21 20:31:34.943 INFO 2180 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean : Mapping servlet: 'dispatcherServlet' to [/] 27 2018-03-21 20:31:34.948 INFO 2180 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*] 28 2018-03-21 20:31:34.949 INFO 2180 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*] 29 2018-03-21 20:31:34.950 INFO 2180 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'httpPutFormContentFilter' to: [/*] 30 2018-03-21 20:31:34.950 INFO 2180 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'requestContextFilter' to: [/*] 31 2018-03-21 20:31:34.950 INFO 2180 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'webStatFilter' to urls: [/*] 32 2018-03-21 20:31:35.136 ERROR 2180 --- [ main] c.a.druid.pool.DruidAbstractDataSource : maxIdle is deprecated 33 2018-03-21 20:31:35.172 INFO 2180 --- [ main] b.u.c.database.DruidDataSourceConfig : druid datasource config : { 34 CreateTime:"2018-03-21 20:31:35", 35 ActiveCount:0, 36 PoolingCount:0, 37 CreateCount:0, 38 DestroyCount:0, 39 CloseCount:0, 40 ConnectCount:0, 41 Connections:[ 42 ] 43 } 44 45 [ 46 ] 47 2018-03-21 20:31:36.521 INFO 2180 --- [ main] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for @ControllerAdvice: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@594001dc: startup date [Wed Mar 21 20:31:27 CST 2018]; root of context hierarchy 48 2018-03-21 20:31:36.648 INFO 2180 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/sender]}" onto public void bhz.uts.service.api.SenderTradeDetailController.sender(java.lang.Integer) throws java.lang.Exception 49 2018-03-21 20:31:36.657 INFO 2180 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error]}" onto public org.springframework.http.ResponseEntity<java.util.Map<java.lang.String, java.lang.Object>> org.springframework.boot.autoconfigure.web.BasicErrorController.error(javax.servlet.http.HttpServletRequest) 50 2018-03-21 20:31:36.658 INFO 2180 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error],produces=[text/html]}" onto public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse) 51 2018-03-21 20:31:36.726 INFO 2180 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler] 52 2018-03-21 20:31:36.727 INFO 2180 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler] 53 2018-03-21 20:31:36.886 INFO 2180 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler] 54 2018-03-21 20:31:38.052 INFO 2180 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Registering beans for JMX exposure on startup 55 2018-03-21 20:31:38.054 INFO 2180 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Bean with name 'dataSource' has been autodetected for JMX exposure 56 2018-03-21 20:31:38.065 INFO 2180 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Located MBean 'dataSource': registering with JMX server as MBean [com.alibaba.druid.pool:name=dataSource,type=DruidDataSource] 57 spring 加载完毕.. 58 远程服务器端已经连接.. 可以进行数据通信.... 59 2018-03-21 20:31:40.279 INFO 2180 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat started on port(s): 8001 (http) 60 2018-03-21 20:31:40.284 INFO 2180 --- [ main] bhz.uts.UtsSenderApplication : Started UtsSenderApplication in 14.68 seconds (JVM running for 19.764) 61 2018-03-21 20:31:46.045 INFO 2180 --- [nio-8001-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring FrameworkServlet 'dispatcherServlet' 62 2018-03-21 20:31:46.046 INFO 2180 --- [nio-8001-exec-1] o.s.web.servlet.DispatcherServlet : FrameworkServlet 'dispatcherServlet': initialization started 63 2018-03-21 20:31:46.186 INFO 2180 --- [nio-8001-exec-1] o.s.web.servlet.DispatcherServlet : FrameworkServlet 'dispatcherServlet': initialization completed in 140 ms 64 2017-06-24 20:14:49 65 2018-03-21 20:31:48.117 INFO 2180 --- [nio-8001-exec-1] com.alibaba.druid.pool.DruidDataSource : {dataSource-1} inited 66 2017-01-14 14:49:26 67 2017-02-05 13:26:04 68 2017-05-22 04:10:30 69 2017-05-22 14:36:46 70 更新同步标志-----------: id: d2119747-2d03-11e8-b721-6c881435c21c 71 更新同步标志-----------: id: d37f09f8-2d03-11e8-b721-6c881435c21c 72 更新同步标志-----------: id: d3c0cde9-2d03-11e8-b721-6c881435c21c 73 更新同步标志-----------: id: d3f3017a-2d03-11e8-b721-6c881435c21c 74 更新同步标志-----------: id: d424239b-2d03-11e8-b721-6c881435c21c 75 2017-03-18 12:42:58 76 更新同步标志-----------: id: d460905c-2d03-11e8-b721-6c881435c21c 77 2017-01-17 16:25:36 78 更新同步标志-----------: id: d48e300d-2d03-11e8-b721-6c881435c21c 79 2017-01-17 23:11:41 80 更新同步标志-----------: id: d4babe4e-2d03-11e8-b721-6c881435c21c 81 2017-07-26 14:46:20 82 更新同步标志-----------: id: d4e8ac1f-2d03-11e8-b721-6c881435c21c 83 2017-06-16 18:03:53 84 更新同步标志-----------: id: d51699f0-2d03-11e8-b721-6c881435c21c