1:添加spring-data-redis1.7.1相关jar及测试代码
2:添加fastdfs的相关jar及测试代码 3:修改某些系统文件中项目名称为maat_service(有些系统配置文件里面的项目名称没有改过来)
This commit is contained in:
13
.project
13
.project
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>gk</name>
|
||||
<name>maat_service</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
@@ -30,6 +30,16 @@
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.springframework.ide.eclipse.core.springbuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.springframework.ide.eclipse.boot.validation.springbootbuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.m2e.core.maven2Builder</name>
|
||||
<arguments>
|
||||
@@ -37,6 +47,7 @@
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.springframework.ide.eclipse.core.springnature</nature>
|
||||
<nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
|
||||
<nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
|
||||
@@ -5,10 +5,10 @@ encoding//src/main/resources/jdbc.properties=UTF-8
|
||||
encoding//src/main/resources/log4j.properties=UTF-8
|
||||
encoding//src/main/resources/matt.properties=UTF-8
|
||||
encoding//src/main/resources/nis.properties=UTF-8
|
||||
encoding//src/main/resources/redis.properties=UTF-8
|
||||
encoding//src/main/resources/table.properties=UTF-8
|
||||
encoding//src/main/webapp/WEB-INF/include/header.jsp=UTF-8
|
||||
encoding//src/main/webapp/WEB-INF/tlds/fns.tld=UTF-8
|
||||
encoding//src/main/webapp/WEB-INF/views/letter/process/errorView.jsp=UTF-8
|
||||
encoding//src/main/webapp/static/common/jeesite.css=UTF-8
|
||||
encoding//src/test/java=UTF-8
|
||||
encoding/<project>=UTF-8
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
|
||||
<wb-module deploy-name="gk">
|
||||
<wb-module deploy-name="maat_service-0.0.1-SNAPSHOT">
|
||||
<wb-resource deploy-path="/" source-path="/target/m2e-wtp/web-resources"/>
|
||||
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
|
||||
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
|
||||
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
|
||||
<property name="java-output-path" value="/gk/target/classes"/>
|
||||
<property name="context-root" value="gk"/>
|
||||
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/test/java"/>
|
||||
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/test/resources"/>
|
||||
<property name="java-output-path" value="/maat_service/target/classes"/>
|
||||
<property name="context-root" value="maat_service"/>
|
||||
</wb-module>
|
||||
</project-modules>
|
||||
|
||||
138
pom.xml
138
pom.xml
@@ -14,9 +14,9 @@
|
||||
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>
|
||||
<packaging>war</packaging>
|
||||
<name>gk</name>
|
||||
<name>maat_service</name>
|
||||
<groupId>com.nis.springmvc</groupId>
|
||||
<artifactId>gk</artifactId>
|
||||
<artifactId>maat_service</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<!-- 仓库地址构建 -->
|
||||
<repositories>
|
||||
@@ -37,6 +37,11 @@
|
||||
|
||||
</repositories>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<build>
|
||||
|
||||
<pluginManagement>
|
||||
@@ -64,19 +69,19 @@
|
||||
</pluginExecution>
|
||||
|
||||
<!-- mybatis-generator-plugin -->
|
||||
<pluginExecution>
|
||||
<pluginExecutionFilter>
|
||||
<groupId>org.mybatis.generator</groupId>
|
||||
<artifactId>mybatis-generator-maven-plugin</artifactId>
|
||||
<versionRange>[1.3.2,)</versionRange>
|
||||
<goals>
|
||||
<goal>generate</goal>
|
||||
</goals>
|
||||
</pluginExecutionFilter>
|
||||
<action>
|
||||
<ignore />
|
||||
</action>
|
||||
</pluginExecution>
|
||||
<!-- <pluginExecution> -->
|
||||
<!-- <pluginExecutionFilter> -->
|
||||
<!-- <groupId>org.mybatis.generator</groupId> -->
|
||||
<!-- <artifactId>mybatis-generator-maven-plugin</artifactId> -->
|
||||
<!-- <versionRange>[1.3.2,)</versionRange> -->
|
||||
<!-- <goals> -->
|
||||
<!-- <goal>generate</goal> -->
|
||||
<!-- </goals> -->
|
||||
<!-- </pluginExecutionFilter> -->
|
||||
<!-- <action> -->
|
||||
<!-- <ignore /> -->
|
||||
<!-- </action> -->
|
||||
<!-- </pluginExecution> -->
|
||||
</pluginExecutions>
|
||||
</lifecycleMappingMetadata>
|
||||
<encoding>UTF-8</encoding>
|
||||
@@ -84,52 +89,47 @@
|
||||
</plugin>
|
||||
</plugins>
|
||||
</pluginManagement>
|
||||
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.mybatis.generator</groupId>
|
||||
<artifactId>mybatis-generator-maven-plugin</artifactId>
|
||||
<version>1.3.2</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>Generate MyBatis Artifacts</id>
|
||||
<goals>
|
||||
<goal>generate</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
<!-- <plugin> -->
|
||||
<!-- <groupId>org.mybatis.generator</groupId> -->
|
||||
<!-- <artifactId>mybatis-generator-maven-plugin</artifactId> -->
|
||||
<!-- <version>1.3.2</version> -->
|
||||
<!-- <executions> -->
|
||||
<!-- <execution> -->
|
||||
<!-- <id>Generate MyBatis Artifacts</id> -->
|
||||
<!-- <goals> -->
|
||||
<!-- <goal>generate</goal> -->
|
||||
<!-- </goals> -->
|
||||
<!-- </execution> -->
|
||||
|
||||
</executions>
|
||||
<configuration>
|
||||
<verbose>true</verbose>
|
||||
<overwrite>true</overwrite>
|
||||
</configuration>
|
||||
<!-- </executions> -->
|
||||
<!-- <configuration> -->
|
||||
<!-- <verbose>true</verbose> -->
|
||||
<!-- <overwrite>true</overwrite> -->
|
||||
<!-- </configuration> -->
|
||||
|
||||
<dependencies>
|
||||
<!-- <dependencies> -->
|
||||
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
<version>5.1.36</version>
|
||||
</dependency>
|
||||
<!-- <dependency> -->
|
||||
<!-- <groupId>mysql</groupId> -->
|
||||
<!-- <artifactId>mysql-connector-java</artifactId> -->
|
||||
<!-- <version>5.1.36</version> -->
|
||||
<!-- </dependency> -->
|
||||
|
||||
<dependency>
|
||||
<groupId>org.mybatis</groupId>
|
||||
<artifactId>mybatis</artifactId>
|
||||
<version>${mybatis.version}</version>
|
||||
</dependency>
|
||||
<!-- <dependency> -->
|
||||
<!-- <groupId>org.mybatis</groupId> -->
|
||||
<!-- <artifactId>mybatis</artifactId> -->
|
||||
<!-- <version>${mybatis.version}</version> -->
|
||||
<!-- </dependency> -->
|
||||
|
||||
<dependency>
|
||||
<groupId>org.mybatis.generator</groupId>
|
||||
<artifactId>mybatis-generator-core</artifactId>
|
||||
<version>1.3.2</version>
|
||||
</dependency>
|
||||
<!-- <dependency> -->
|
||||
<!-- <groupId>org.mybatis.generator</groupId> -->
|
||||
<!-- <artifactId>mybatis-generator-core</artifactId> -->
|
||||
<!-- <version>1.3.2</version> -->
|
||||
<!-- </dependency> -->
|
||||
<!-- </dependencies> -->
|
||||
|
||||
|
||||
|
||||
</dependencies>
|
||||
|
||||
|
||||
</plugin>
|
||||
<!-- </plugin> -->
|
||||
|
||||
<plugin>
|
||||
<groupId>org.mortbay.jetty</groupId>
|
||||
@@ -159,6 +159,14 @@
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<properties>
|
||||
<!-- spring 版本号 -->
|
||||
<spring.version>4.1.7.RELEASE</spring.version>
|
||||
@@ -173,15 +181,15 @@
|
||||
<xstream.version>1.4.7</xstream.version>
|
||||
<poi.version>3.9</poi.version>
|
||||
<slf4j.version>1.7.7</slf4j.version>
|
||||
<jedis.version>2.9.0</jedis.version>
|
||||
<spring-data-redis.version>1.7.1.RELEASE</spring-data-redis.version>
|
||||
<maven.compiler.encoding>UTF-8</maven.compiler.encoding>
|
||||
</properties>
|
||||
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.11</version>
|
||||
<version>4.12</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
@@ -304,7 +312,7 @@
|
||||
<dependency>
|
||||
<groupId>redis.clients</groupId>
|
||||
<artifactId>jedis</artifactId>
|
||||
<version>2.9.0</version>
|
||||
<version>${jedis.version}</version>
|
||||
</dependency>
|
||||
<!-- CACHE end -->
|
||||
|
||||
@@ -610,7 +618,19 @@
|
||||
<artifactId>httpclient</artifactId>
|
||||
<version>4.4</version>
|
||||
</dependency>
|
||||
|
||||
<!-- spring-data-redis -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.data</groupId>
|
||||
<artifactId>spring-data-redis</artifactId>
|
||||
<version>${spring-data-redis.version}</version>
|
||||
</dependency>
|
||||
<!-- 引入fastdfs-java-client,maven中央仓库没有这个jar需要从github上下载后安装到本地仓库中 -->
|
||||
<dependency>
|
||||
<groupId>org.csource</groupId>
|
||||
<artifactId>fastdfs-client-java</artifactId>
|
||||
<version>1.27-SNAPSHOT</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
||||
</project>
|
||||
|
||||
28
src/main/java/com/nis/datasource/DynamicJedisDataBase.java
Normal file
28
src/main/java/com/nis/datasource/DynamicJedisDataBase.java
Normal file
@@ -0,0 +1,28 @@
|
||||
package com.nis.datasource;
|
||||
|
||||
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
|
||||
import com.nis.web.service.SpringContextHolder;
|
||||
|
||||
/**
|
||||
*
|
||||
* <p>Title: DynamicJedisDataBase</p>
|
||||
* <p>Description: 设置使用redis的哪个数据库</p>
|
||||
* <p>Company: IIE</p>
|
||||
* @author rkg
|
||||
* @date 2018年5月17日
|
||||
*
|
||||
*/
|
||||
public class DynamicJedisDataBase {
|
||||
/**
|
||||
* 设置redisTemplate使用哪个数据库,默认使用的是数据库0
|
||||
* @param index
|
||||
* @param redisTemplate
|
||||
*/
|
||||
public static void setRedisDataBase(int index, RedisTemplate redisTemplate) {
|
||||
JedisConnectionFactory connectionFactory = SpringContextHolder.getBean("connectionFactory");
|
||||
connectionFactory.setDatabase(index);
|
||||
redisTemplate.setConnectionFactory(connectionFactory);
|
||||
}
|
||||
}
|
||||
@@ -26,6 +26,7 @@ import com.nis.util.StringUtils;
|
||||
import com.nis.web.controller.BaseRestController;
|
||||
import com.nis.web.service.SaveRequestLogThread;
|
||||
import com.nis.web.service.ServicesRequestLogService;
|
||||
import com.nis.web.service.restful.TestRedisService;
|
||||
import com.nis.web.service.restful.ConfigSourcesService;
|
||||
import com.wordnik.swagger.annotations.Api;
|
||||
import com.wordnik.swagger.annotations.ApiOperation;
|
||||
@@ -48,6 +49,22 @@ public class ConfigSourcesController extends BaseRestController {
|
||||
@Autowired
|
||||
protected ServicesRequestLogService servicesRequestLogService;
|
||||
|
||||
@Autowired
|
||||
TestRedisService testRedisServiceimpl;
|
||||
|
||||
@RequestMapping(value = "/save", method = RequestMethod.GET)
|
||||
@ApiOperation(value = "test redis", httpMethod = "GET", response = Map.class, notes = "测试redis事务的crontroller")
|
||||
@ApiParam(value = "test redis", name = "测试redis事务的crontroller", required = true)
|
||||
public String testRedis() {
|
||||
try {
|
||||
testRedisServiceimpl.saveConfigCompile();
|
||||
return "ok";
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return "false";
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/cfg/v1/configSources", method = RequestMethod.POST)
|
||||
@ApiOperation(value = "业务配置存储", httpMethod = "POST", response = Map.class, notes = "对有效的配置(封堵|监测|白名单)存储")
|
||||
@ApiParam(value = "业务配置数据源", name = "configSource", required = true)
|
||||
@@ -123,10 +140,12 @@ public class ConfigSourcesController extends BaseRestController {
|
||||
checkOpAction(thread, System.currentTimeMillis() - start, opAction, 2);
|
||||
String msg = "";
|
||||
ConfigCompile compile = configSource.getConfigCompileList().get(0);
|
||||
if(StringUtil.isEmpty(compile.getGroupRelationList())&&StringUtil.isEmpty(compile.getIpRegionList())&&StringUtil.isEmpty(compile.getStrRegionList())&&StringUtil.isEmpty(compile.getNumRegionList())){
|
||||
if (StringUtil.isEmpty(compile.getGroupRelationList()) && StringUtil.isEmpty(compile.getIpRegionList())
|
||||
&& StringUtil.isEmpty(compile.getStrRegionList())
|
||||
&& StringUtil.isEmpty(compile.getNumRegionList())) {
|
||||
msg = configSourcesService.updateByJDBCThread3(thread, start, configSource.getConfigCompileList(),
|
||||
configSource.getOpTime(), sb);
|
||||
}else{
|
||||
} else {
|
||||
msg = configSourcesService.updateByJDBCThread12(thread, start, configSource.getConfigCompileList(),
|
||||
configSource.getOpTime(), sb);
|
||||
}
|
||||
@@ -240,7 +259,8 @@ public class ConfigSourcesController extends BaseRestController {
|
||||
|
||||
}
|
||||
}
|
||||
Map<Integer, String> throwExceptionInfo = OracleErrorCodeUtil.throwExceptionInfo(errorCode);
|
||||
Map<Integer, String> throwExceptionInfo = OracleErrorCodeUtil
|
||||
.throwExceptionInfo(errorCode);
|
||||
for (int errorNum : throwExceptionInfo.keySet()) {
|
||||
if (errorNum == 998) {
|
||||
thread.setExceptionInfo(e.toString());
|
||||
|
||||
@@ -0,0 +1,110 @@
|
||||
package com.nis.web.controller.restful;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.csource.common.MyException;
|
||||
import org.csource.common.NameValuePair;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Controller;
|
||||
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.ResponseBody;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import com.nis.web.service.fdfs.FastDFSFile;
|
||||
import com.nis.web.service.fdfs.FileManager;
|
||||
|
||||
/**
|
||||
* <p>Title: FastDFSController.java</p>
|
||||
* <p>Description: fastdfs测试controller</p>
|
||||
* <p>Company: IIE</p>
|
||||
* @author rkg
|
||||
* @date 2018年5月16日
|
||||
*
|
||||
*/
|
||||
@Controller
|
||||
public class FastDFSController {
|
||||
public static void main(String[] args) {
|
||||
String path = new FastDFSController().testAdd();
|
||||
//String path = "M00/00/01/CgAGwFr786aAegOQAADz3NN2rlY283.jpg";
|
||||
new FastDFSController().testDelete(path);
|
||||
|
||||
}
|
||||
|
||||
public void testDelete(String filePath) {
|
||||
filePath = filePath.substring(filePath.indexOf("group"));
|
||||
String groupName=filePath.substring(0,filePath.indexOf("/"));
|
||||
filePath=filePath.substring(filePath.indexOf("/")+1);
|
||||
Integer a = FileManager.delete_file(groupName, filePath);
|
||||
System.out.println(a);
|
||||
}
|
||||
|
||||
public String testAdd() {
|
||||
String filePath = "d:/1.jpg";
|
||||
File file = new File(filePath);
|
||||
String fileName = file.getName();
|
||||
String ext = fileName.substring(fileName.lastIndexOf(".") + 1);
|
||||
NameValuePair[] meta_list = new NameValuePair[4];
|
||||
meta_list[0] = new NameValuePair("fileName", fileName);
|
||||
meta_list[1] = new NameValuePair("fileLength", String.valueOf(file.length()));
|
||||
meta_list[2] = new NameValuePair("fileExt", ext);
|
||||
meta_list[3] = new NameValuePair("fileAuthor", "rkg");
|
||||
String successFilePath = FileManager.upload(new FastDFSFile(getByte(file), ext), null);
|
||||
System.out.println("上传成功返回的路径是" + successFilePath);
|
||||
return successFilePath;
|
||||
}
|
||||
|
||||
private byte[] getByte(File file) {
|
||||
byte[] bf = null;
|
||||
try {
|
||||
InputStream fis = new FileInputStream(file);
|
||||
bf = new byte[fis.available()];
|
||||
fis.read(bf);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return bf;
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value = "/add", method = RequestMethod.POST)
|
||||
// public String add(@Validated User user, MultipartFile attach,
|
||||
// HttpServletRequest request)
|
||||
public String add(MultipartFile attach, HttpServletRequest request) throws IOException, MyException {
|
||||
// 获取文件后缀名
|
||||
String ext = attach.getOriginalFilename().substring(attach.getOriginalFilename().lastIndexOf(".") + 1);
|
||||
FastDFSFile file = new FastDFSFile(attach.getBytes(), ext);
|
||||
NameValuePair[] meta_list = new NameValuePair[4];
|
||||
meta_list[0] = new NameValuePair("fileName", attach.getOriginalFilename());
|
||||
meta_list[1] = new NameValuePair("fileLength", String.valueOf(attach.getSize()));
|
||||
meta_list[2] = new NameValuePair("fileExt", ext);
|
||||
meta_list[3] = new NameValuePair("fileAuthor", "rkg");
|
||||
String filePath = FileManager.upload(file, meta_list);
|
||||
// user.setFilePath(filePath);
|
||||
// users.put(user.getUsername(), user);
|
||||
return filePath;
|
||||
}
|
||||
|
||||
// public ResponseEntity<byte[]> download(@PathVariable String filePath,
|
||||
// HttpServletResponse response)
|
||||
@RequestMapping(value = "/download", method = RequestMethod.GET)
|
||||
public ResponseEntity<byte[]> download(@RequestParam("filePath") String filePath, HttpServletResponse response)
|
||||
throws IOException, MyException {
|
||||
// User u = users.get(username);
|
||||
// String filePath = u.getFilePath();
|
||||
// String filePath = "";
|
||||
String substr = filePath.substring(filePath.indexOf("group"));
|
||||
String group = substr.split("/")[0];
|
||||
String remoteFileName = substr.substring(substr.indexOf("/") + 1);
|
||||
// 重命名文件
|
||||
String specFileName = "rkg" + substr.substring(substr.indexOf("."));
|
||||
return FileManager.download(group, remoteFileName, specFileName);
|
||||
}
|
||||
}
|
||||
13
src/main/java/com/nis/web/dao/impl/BaseRedisDao.java
Normal file
13
src/main/java/com/nis/web/dao/impl/BaseRedisDao.java
Normal file
@@ -0,0 +1,13 @@
|
||||
package com.nis.web.dao.impl;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public abstract class BaseRedisDao<K, V> {
|
||||
|
||||
@Autowired
|
||||
protected RedisTemplate<K, V> redisTemplate;
|
||||
|
||||
}
|
||||
80
src/main/java/com/nis/web/service/fdfs/FastDFSFile.java
Normal file
80
src/main/java/com/nis/web/service/fdfs/FastDFSFile.java
Normal file
@@ -0,0 +1,80 @@
|
||||
package com.nis.web.service.fdfs;
|
||||
|
||||
/**
|
||||
* <p>Title: FastDFSFile.java</p>
|
||||
* <p>Description: </p>
|
||||
* <p>Company: IIE</p>
|
||||
* @author rkg
|
||||
* @date 2018年5月16日
|
||||
*
|
||||
*/
|
||||
|
||||
public class FastDFSFile extends FileManagerConfig {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private byte[] content;
|
||||
private String name;
|
||||
private String ext;
|
||||
private String length;
|
||||
private String author = FILE_DEFAULT_AUTHOR;
|
||||
|
||||
public FastDFSFile(byte[] content, String ext) {
|
||||
this.content = content;
|
||||
this.ext = ext;
|
||||
}
|
||||
|
||||
public FastDFSFile(byte[] content, String name, String ext) {
|
||||
this.content = content;
|
||||
this.name = name;
|
||||
this.ext = ext;
|
||||
}
|
||||
|
||||
public FastDFSFile(byte[] content, String name, String ext, String length, String author) {
|
||||
this.content = content;
|
||||
this.name = name;
|
||||
this.ext = ext;
|
||||
this.length = length;
|
||||
this.author = author;
|
||||
}
|
||||
|
||||
public byte[] getContent() {
|
||||
return content;
|
||||
}
|
||||
|
||||
public void setContent(byte[] content) {
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getExt() {
|
||||
return ext;
|
||||
}
|
||||
|
||||
public void setExt(String ext) {
|
||||
this.ext = ext;
|
||||
}
|
||||
|
||||
public String getLength() {
|
||||
return length;
|
||||
}
|
||||
|
||||
public void setLength(String length) {
|
||||
this.length = length;
|
||||
}
|
||||
|
||||
public String getAuthor() {
|
||||
return author;
|
||||
}
|
||||
|
||||
public void setAuthor(String author) {
|
||||
this.author = author;
|
||||
}
|
||||
|
||||
}
|
||||
108
src/main/java/com/nis/web/service/fdfs/FileManager.java
Normal file
108
src/main/java/com/nis/web/service/fdfs/FileManager.java
Normal file
@@ -0,0 +1,108 @@
|
||||
package com.nis.web.service.fdfs;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import org.csource.common.NameValuePair;
|
||||
import org.csource.fastdfs.ClientGlobal;
|
||||
import org.csource.fastdfs.StorageClient;
|
||||
import org.csource.fastdfs.StorageServer;
|
||||
import org.csource.fastdfs.TrackerClient;
|
||||
import org.csource.fastdfs.TrackerServer;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
|
||||
/**
|
||||
* <p>Title: FileManager.java</p>
|
||||
* <p>Description: </p>
|
||||
* <p>Company: IIE</p>
|
||||
* @author rkg
|
||||
* @date 2018年5月16日
|
||||
*
|
||||
*/
|
||||
|
||||
public class FileManager extends FileManagerConfig {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private static TrackerClient trackerClient;
|
||||
private static TrackerServer trackerServer;
|
||||
private static StorageServer storageServer;
|
||||
private static StorageClient storageClient;
|
||||
|
||||
static {
|
||||
try {
|
||||
String classPath = new File(FileManager.class.getResource("/").getFile()).getCanonicalPath();
|
||||
String fdfsClientConfigFilePath = classPath + File.separator + CLIENT_CONFIG_FILE;
|
||||
ClientGlobal.init(fdfsClientConfigFilePath);
|
||||
trackerClient = new TrackerClient();
|
||||
trackerServer = trackerClient.getConnection();
|
||||
storageClient = new StorageClient(trackerServer, storageServer);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 向fastdfs上传文件
|
||||
* @param file
|
||||
* @param valuePairs
|
||||
* @return
|
||||
*/
|
||||
public static String upload(FastDFSFile file, NameValuePair[] valuePairs) {
|
||||
String[] uploadResults = null;
|
||||
try {
|
||||
// uploadResults = storageClient.upload_file(file.getContent(), file.getExt(),
|
||||
// valuePairs);
|
||||
uploadResults = storageClient.upload_file(file.getContent(), file.getExt(), valuePairs);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
String groupName = uploadResults[0];
|
||||
String remoteFileName = uploadResults[1];
|
||||
|
||||
String fileAbsolutePath = PROTOCOL + TRACKER_NGNIX_ADDR
|
||||
// + trackerServer.getInetSocketAddress().getHostName()
|
||||
// + SEPARATOR + TRACKER_NGNIX_PORT
|
||||
+ SEPARATOR + groupName + SEPARATOR + remoteFileName;
|
||||
return fileAbsolutePath;
|
||||
}
|
||||
|
||||
/**
|
||||
* 从fastdfs下载文件
|
||||
* @param groupName
|
||||
* @param remoteFileName
|
||||
* @param specFileName
|
||||
* @return
|
||||
*/
|
||||
public static ResponseEntity<byte[]> download(String groupName, String remoteFileName, String specFileName) {
|
||||
byte[] content = null;
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
try {
|
||||
content = storageClient.download_file(groupName, remoteFileName);
|
||||
headers.setContentDispositionFormData("attachment",
|
||||
new String(specFileName.getBytes("UTF-8"), "iso-8859-1"));
|
||||
headers.setContentType(MediaType.APPLICATION_OCTET_STREAM);
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
return new ResponseEntity<byte[]>(content, headers, HttpStatus.CREATED);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据组和文件名删除文件
|
||||
* @param group 文件所属组
|
||||
* @param filePath 文件存放路径,不包含group,例如文件url是http://10.0.6.192/group1/M00/00/01/CgAGwFr786aAegOQAADz3NN2rlY283.jpg,那么filePath=/M00/00/01/CgAGwFr786aAegOQAADz3NN2rlY283.jpg
|
||||
* @return 返回0代表成功,其他则失败
|
||||
*/
|
||||
public static Integer delete_file(String group, String filePath) {
|
||||
Integer result = -1;
|
||||
try {
|
||||
result = storageClient.delete_file(group, filePath);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.nis.web.service.fdfs;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* <p>Title: FileManagerConfig.java</p>
|
||||
* <p>Description: </p>
|
||||
* <p>Company: IIE</p>
|
||||
* @author rkg
|
||||
* @date 2018年5月16日
|
||||
*
|
||||
*/
|
||||
|
||||
public class FileManagerConfig implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public static final String FILE_DEFAULT_AUTHOR = "renkaige";
|
||||
|
||||
public static final String PROTOCOL = "http://";
|
||||
|
||||
public static final String SEPARATOR = "/";
|
||||
|
||||
public static final String TRACKER_NGNIX_ADDR = "10.0.6.192";
|
||||
|
||||
public static final String TRACKER_NGNIX_PORT = "";
|
||||
|
||||
public static final String CLIENT_CONFIG_FILE = "fdfs_client.conf";
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.nis.web.service.restful;
|
||||
|
||||
/**
|
||||
*
|
||||
* <p>Title: TestRedisService</p>
|
||||
* <p>Description: 测试redis事务</p>
|
||||
* <p>Company: IIE</p>
|
||||
* @author rkg
|
||||
* @date 2018年5月17日
|
||||
*
|
||||
*/
|
||||
public interface TestRedisService {
|
||||
public void saveConfigCompile();
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.nis.web.service.restful;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import com.nis.datasource.DynamicJedisDataBase;
|
||||
import com.nis.web.dao.impl.BaseRedisDao;
|
||||
|
||||
@Service("testRedisServiceimpl")
|
||||
public class TestRedisServiceimpl extends BaseRedisDao<String, String> implements TestRedisService {
|
||||
@Transactional
|
||||
public void saveConfigCompile() {
|
||||
DynamicJedisDataBase.setRedisDataBase(2, redisTemplate);
|
||||
for (int i = 0; i < 10; i++) {
|
||||
redisTemplate.boundZSetOps("1").add("a" + i, i);
|
||||
if (i == 5) {
|
||||
// int a = 1 / 0;
|
||||
}
|
||||
}
|
||||
// 切换redis数据库
|
||||
DynamicJedisDataBase.setRedisDataBase(3, redisTemplate);
|
||||
for (int i = 10; i < 20; i++) {
|
||||
redisTemplate.boundZSetOps("1").add("a" + i, i);
|
||||
if (i == 5) {
|
||||
// int a = 1 / 0;
|
||||
}
|
||||
}
|
||||
DynamicJedisDataBase.setRedisDataBase(4, redisTemplate);
|
||||
for (int i = 20; i < 30; i++) {
|
||||
redisTemplate.boundZSetOps("1").add("a" + i, i);
|
||||
if (i == 25) {
|
||||
int a = 1 / 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
52
src/main/resources/applicationContext-redis.xml
Normal file
52
src/main/resources/applicationContext-redis.xml
Normal file
@@ -0,0 +1,52 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
|
||||
xmlns:jdbc="http://www.springframework.org/schema/jdbc" xmlns:jee="http://www.springframework.org/schema/jee"
|
||||
xmlns:p="http://www.springframework.org/schema/p" xmlns:tx="http://www.springframework.org/schema/tx"
|
||||
xmlns:tool="http://www.springframework.org/schema/tool" xmlns:aop="http://www.springframework.org/schema/aop"
|
||||
xmlns:util="http://www.springframework.org/schema/util" xmlns:task="http://www.springframework.org/schema/task"
|
||||
xsi:schemaLocation="
|
||||
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.1.xsd
|
||||
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.1.xsd
|
||||
http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-4.1.xsd
|
||||
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-4.1.xsd
|
||||
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.1.xsd
|
||||
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.1.xsd
|
||||
http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-4.1.xsd
|
||||
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.1.xsd"
|
||||
default-lazy-init="true">
|
||||
<!-- 加载配置文件 -->
|
||||
<context:property-placeholder
|
||||
ignore-unresolvable="true" location="classpath:jdbc.properties" />
|
||||
|
||||
<bean id="poolConfig" class="redis.clients.jedis.JedisPoolConfig">
|
||||
<property name="maxIdle" value="${redis.maxIdle}" />
|
||||
<property name="maxTotal" value="${redis.maxTotal}" />
|
||||
<property name="maxWaitMillis" value="${redis.maxWaitMillis}" />
|
||||
<property name="testOnBorrow" value="${redis.testOnBorrow}" />
|
||||
</bean>
|
||||
<!-- 默认使用数据库0,设置connectionFactory为非单例模式,方便选择redis数据库 -->
|
||||
<bean id="connectionFactory"
|
||||
class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory"
|
||||
p:host-name="${redis.host}" p:port="${redis.port}" p:pool-config-ref="poolConfig"
|
||||
p:database="0" scope="prototype" />
|
||||
<!-- p:password="" -->
|
||||
|
||||
|
||||
<bean id="stringRedisSerializer"
|
||||
class="org.springframework.data.redis.serializer.StringRedisSerializer" />
|
||||
<bean id="redisTemplate" class="org.springframework.data.redis.core.RedisTemplate">
|
||||
<property name="connectionFactory" ref="connectionFactory" />
|
||||
<!-- 设置key和value的序列化方式,默认使用的是JdkSerializationRedisSerializer,key会被序列化为\xac\xed\x00\x056\x00 -->
|
||||
<property name="keySerializer" ref="stringRedisSerializer" />
|
||||
<property name="valueSerializer" ref="stringRedisSerializer" />
|
||||
<property name="hashKeySerializer" ref="stringRedisSerializer" />
|
||||
<property name="hashValueSerializer" ref="stringRedisSerializer" />
|
||||
<!-- 设置开启事务 -->
|
||||
<property name="enableTransactionSupport" value="true" />
|
||||
</bean>
|
||||
|
||||
|
||||
|
||||
|
||||
</beans>
|
||||
14
src/main/resources/fastdfs-client.properties
Normal file
14
src/main/resources/fastdfs-client.properties
Normal file
@@ -0,0 +1,14 @@
|
||||
## fastdfs-client.properties
|
||||
|
||||
fastdfs.connect_timeout_in_seconds = 5
|
||||
fastdfs.network_timeout_in_seconds = 30
|
||||
|
||||
fastdfs.charset = UTF-8
|
||||
|
||||
fastdfs.http_anti_steal_token = false
|
||||
fastdfs.http_secret_key = FastDFS1234567890
|
||||
fastdfs.http_tracker_http_port = 80
|
||||
|
||||
#fastdfs.tracker_servers = 10.0.11.201:22122,10.0.11.202:22122,10.0.11.203:22122
|
||||
fastdfs.tracker_servers = 10.0.6.192:22122
|
||||
|
||||
10
src/main/resources/fdfs_client.conf
Normal file
10
src/main/resources/fdfs_client.conf
Normal file
@@ -0,0 +1,10 @@
|
||||
connect_timeout = 2
|
||||
network_timeout = 30
|
||||
charset = UTF-8
|
||||
http.tracker_http_port = 8080
|
||||
http.anti_steal_token = no
|
||||
http.secret_key = FastDFS1234567890
|
||||
|
||||
tracker_server = 10.0.6.192:22122
|
||||
#tracker_server = 10.0.11.248:22122
|
||||
#tracker_server = 10.0.11.249:22122
|
||||
@@ -84,9 +84,9 @@ jdbc.hiveA.url=jdbc:hive2://10.3.130.24:10000/default
|
||||
jdbc.hiveA.username=xa_z2_mesa
|
||||
jdbc.hiveA.key=aC/8fTC9vfPVhCk+CDzbAQ==
|
||||
#加密后密码
|
||||
#jdbc.hiveA.password=V3GyFlG8Mg01bTt8ykFVaA==
|
||||
jdbc.hiveA.password=V3GyFlG8Mg01bTt8ykFVaA==
|
||||
#实际密码
|
||||
jdbc.hiveA.password=123!@#qwe
|
||||
#jdbc.hiveA.password=123!@#qwe
|
||||
|
||||
|
||||
|
||||
@@ -98,9 +98,9 @@ jdbc.hiveB.url=jdbc:hive2://10.3.130.25:10000/default
|
||||
jdbc.hiveB.username=xa_z2_mesa
|
||||
jdbc.hiveB.key=aC/8fTC9vfPVhCk+CDzbAQ==
|
||||
#加密后密码
|
||||
#jdbc.hiveB.password=V3GyFlG8Mg01bTt8ykFVaA==
|
||||
jdbc.hiveB.password=V3GyFlG8Mg01bTt8ykFVaA==
|
||||
#实际密码
|
||||
jdbc.hiveB.password=123!@#qwe
|
||||
#jdbc.hiveB.password=123!@#qwe
|
||||
|
||||
|
||||
bonecp.hive.idleMaxAgeInMinutes=60
|
||||
@@ -123,4 +123,13 @@ jdbc.test.username=gk_pztest
|
||||
jdbc.test.key=cV9126WUYdojQjvuKNjidw==
|
||||
jdbc.test.password=OrTu/cLwlduYPW/tmxqNgQ==
|
||||
|
||||
|
||||
#####################################################################################################################################
|
||||
##redis连接
|
||||
#####################################################################################################################################
|
||||
redis.host=10.0.6.228
|
||||
redis.port=6379
|
||||
redis.pass=
|
||||
redis.maxIdle=10
|
||||
redis.maxTotal=15
|
||||
redis.maxWaitMillis=1000
|
||||
redis.testOnBorrow=true
|
||||
|
||||
10
src/main/resources/redis.properties
Normal file
10
src/main/resources/redis.properties
Normal file
@@ -0,0 +1,10 @@
|
||||
#####################################################################################################################################
|
||||
##redis连接
|
||||
#####################################################################################################################################
|
||||
redis.host=10.0.6.228
|
||||
redis.port=6379
|
||||
redis.pass=
|
||||
redis.maxIdle=10
|
||||
redis.maxTotal=15
|
||||
redis.maxWaitMillis=1000
|
||||
redis.testOnBorrow=true
|
||||
@@ -22,7 +22,6 @@
|
||||
http://www.springframework.org/schema/cache/spring-cache.xsd">
|
||||
|
||||
|
||||
|
||||
<!-- 加载配置属性文件 -->
|
||||
<context:property-placeholder
|
||||
ignore-unresolvable="true" location="classpath:nis.properties" />
|
||||
@@ -47,28 +46,33 @@
|
||||
<mvc:annotation-driven />
|
||||
|
||||
<bean class="com.nis.restful.SwaggerConfig" />
|
||||
<!-- redis 工具类-->
|
||||
<!-- redis 工具类 -->
|
||||
<bean id="redisDao" class="com.nis.util.redis.RedisDao" />
|
||||
<!-- elasticsearch 工具类 将查询转化为elasticsearch-sql支持的语法-->
|
||||
<bean id="elasticsearchSqlDao" class="com.nis.util.elasticsearch.ElasticsearchSqlDao"/>
|
||||
<!-- elasticsearch 工具类 将查询转化为elasticsearch-sql支持的语法 -->
|
||||
<bean id="elasticsearchSqlDao" class="com.nis.util.elasticsearch.ElasticsearchSqlDao" />
|
||||
<!-- 定义httpclient连接池 -->
|
||||
<bean id="httpClientConnectionManager" class="org.apache.http.impl.conn.PoolingHttpClientConnectionManager" destroy-method="close">
|
||||
<bean id="httpClientConnectionManager"
|
||||
class="org.apache.http.impl.conn.PoolingHttpClientConnectionManager"
|
||||
destroy-method="close">
|
||||
<!-- 设置连接总数 -->
|
||||
<property name="maxTotal" value="${http.pool.maxTotal}"></property>
|
||||
<!-- 设置每个地址的并发数 -->
|
||||
<property name="defaultMaxPerRoute" value="${http.pool.defaultMaxPerRoute}"></property>
|
||||
</bean>
|
||||
|
||||
<!-- 定义 HttpClient工厂,这里使用HttpClientBuilder构建-->
|
||||
<bean id="httpClientBuilder" class="org.apache.http.impl.client.HttpClientBuilder" factory-method="create">
|
||||
<!-- 定义 HttpClient工厂,这里使用HttpClientBuilder构建 -->
|
||||
<bean id="httpClientBuilder" class="org.apache.http.impl.client.HttpClientBuilder"
|
||||
factory-method="create">
|
||||
<property name="connectionManager" ref="httpClientConnectionManager"></property>
|
||||
</bean>
|
||||
|
||||
<!-- 得到httpClient的实例 -->
|
||||
<bean id="httpClient" factory-bean="httpClientBuilder" factory-method="build"/>
|
||||
<bean id="httpClient" factory-bean="httpClientBuilder"
|
||||
factory-method="build" />
|
||||
|
||||
<!-- 定期清理无效的连接 -->
|
||||
<bean class="com.nis.util.httpclient.IdleConnectionEvictor" destroy-method="shutdown">
|
||||
<bean class="com.nis.util.httpclient.IdleConnectionEvictor"
|
||||
destroy-method="shutdown">
|
||||
<constructor-arg index="0" ref="httpClientConnectionManager" />
|
||||
<!-- 间隔一分钟清理一次 -->
|
||||
<constructor-arg index="1" value="60000" />
|
||||
@@ -77,17 +81,18 @@
|
||||
<!-- 定义requestConfig的工厂 -->
|
||||
<bean id="requestConfigBuilder" class="org.apache.http.client.config.RequestConfig.Builder">
|
||||
<!-- 从连接池中获取到连接的最长时间 -->
|
||||
<property name="connectionRequestTimeout" value="${http.request.connectionRequestTimeout}"/>
|
||||
<property name="connectionRequestTimeout" value="${http.request.connectionRequestTimeout}" />
|
||||
<!-- 创建连接的最长时间 -->
|
||||
<property name="connectTimeout" value="${http.request.connectTimeout}"/>
|
||||
<property name="connectTimeout" value="${http.request.connectTimeout}" />
|
||||
<!-- 数据传输的最长时间 -->
|
||||
<property name="socketTimeout" value="${http.request.socketTimeout}"/>
|
||||
<property name="socketTimeout" value="${http.request.socketTimeout}" />
|
||||
<!-- 提交请求前测试连接是否可用 -->
|
||||
<property name="staleConnectionCheckEnabled" value="${http.request.staleConnectionCheckEnabled}"/>
|
||||
<property name="staleConnectionCheckEnabled" value="${http.request.staleConnectionCheckEnabled}" />
|
||||
</bean>
|
||||
|
||||
<!-- 得到requestConfig实例 -->
|
||||
<bean id="requestConfig" factory-bean="requestConfigBuilder" factory-method="build" />
|
||||
<bean id="requestConfig" factory-bean="requestConfigBuilder"
|
||||
factory-method="build" />
|
||||
<!--事务控制驱动注解,发现注解@Transactional 时,找transactionManager事务管理器 -->
|
||||
<tx:annotation-driven transaction-manager="transactionManager" />
|
||||
|
||||
@@ -95,6 +100,7 @@
|
||||
<!-- autodetection of such annotated controllers -->
|
||||
<context:component-scan base-package="com.nis.web"></context:component-scan>
|
||||
<context:component-scan base-package="com.nis.restful"></context:component-scan>
|
||||
<context:component-scan base-package="com.nis.test"></context:component-scan>
|
||||
|
||||
<!-- 默认的注解映射的支持,org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping -->
|
||||
<mvc:annotation-driven
|
||||
@@ -166,6 +172,15 @@
|
||||
<mvc:exclude-mapping path="/nis/sys/user/toDoTask" />
|
||||
<bean class="com.nis.interceptor.LogInterceptor" />
|
||||
</mvc:interceptor>
|
||||
<!-- 添加restful服务的过滤 -->
|
||||
<mvc:interceptor>
|
||||
<mvc:mapping path="/service/**" />
|
||||
<!-- <mvc:exclude-mapping path="/service/save" /> -->
|
||||
<bean class="com.nis.interceptor.LogInterceptor" />
|
||||
</mvc:interceptor>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- 数据源拦截器,该拦截路径下使用数据源B -->
|
||||
<mvc:interceptor>
|
||||
@@ -215,11 +230,11 @@
|
||||
</bean>
|
||||
|
||||
<!-- 支持Shiro对Controller的方法级AOP安全控制 begin -->
|
||||
<bean
|
||||
class="org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator"
|
||||
depends-on="lifecycleBeanPostProcessor">
|
||||
<property name="proxyTargetClass" value="true" />
|
||||
</bean>
|
||||
<!-- <bean -->
|
||||
<!-- class="org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator" -->
|
||||
<!-- depends-on="lifecycleBeanPostProcessor"> -->
|
||||
<!-- <property name="proxyTargetClass" value="true" /> -->
|
||||
<!-- </bean> -->
|
||||
|
||||
<bean id="annotationMethodHandlerExceptionResolver"
|
||||
class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerExceptionResolver">
|
||||
|
||||
@@ -197,11 +197,11 @@
|
||||
</error-page>
|
||||
|
||||
<!-- 数据字典监听器 -->
|
||||
<listener>
|
||||
<listener-class>
|
||||
com.nis.listener.SystemConfigListener
|
||||
</listener-class>
|
||||
</listener>
|
||||
<!-- <listener> -->
|
||||
<!-- <listener-class> -->
|
||||
<!-- com.nis.listener.SystemConfigListener -->
|
||||
<!-- </listener-class> -->
|
||||
<!-- </listener> -->
|
||||
|
||||
|
||||
|
||||
|
||||
31
src/test/java/com/nis/test/RedisTest.java
Normal file
31
src/test/java/com/nis/test/RedisTest.java
Normal file
@@ -0,0 +1,31 @@
|
||||
package com.nis.test;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.web.WebAppConfiguration;
|
||||
|
||||
import com.nis.web.service.restful.TestRedisService;
|
||||
|
||||
@WebAppConfiguration
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
// @ContextConfiguration(locations =
|
||||
// {"classpath:applicationContext-*.xml,classpath:spring-mvc.xml,classpath:mybatis-config.xml"
|
||||
// })
|
||||
@ContextConfiguration(locations = { "classpath:applicationContext-redis.xml", "classpath:spring-mvc.xml"
|
||||
// ,"classpath:mybatis-config.xml"
|
||||
})
|
||||
public class RedisTest {
|
||||
|
||||
@Autowired
|
||||
TestRedisService configService;
|
||||
|
||||
@Test
|
||||
public void testTrans() {
|
||||
configService.saveConfigCompile();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user