From 400337a86e857a43a6a895120726888acb53014e Mon Sep 17 00:00:00 2001
From: luffy9412 <1029559041@qq.com>
Date: Mon, 18 Sep 2017 19:36:15 +0800
Subject: [PATCH] update
---
makeGif/pom.xml | 57 +++++++++++++++++++
pom.xml | 15 ++++-
...{WebConfig.java => AbstractWebConfig.java} | 9 ++-
.../java/org/pqh/config/WebConfigImpl.java | 36 ++++++++++++
.../org/pqh/controller/AdminController.java | 4 +-
.../org/pqh/controller/BaseController.java | 7 ++-
.../java/org/pqh/model/AbstractModel.java | 2 +
src/main/java/org/pqh/model/Config.java | 5 ++
src/main/java/org/pqh/model/Param.java | 5 ++
.../java/org/pqh/service/BaseService.java | 6 +-
src/main/java/org/pqh/util/Log4jUtil.java | 8 ---
src/main/webapp/WEB-INF/jsp/index.jsp | 2 +-
src/test/java/JunitTest.java | 7 ---
13 files changed, 139 insertions(+), 24 deletions(-)
create mode 100644 makeGif/pom.xml
rename src/main/java/org/pqh/config/{WebConfig.java => AbstractWebConfig.java} (74%)
create mode 100644 src/main/java/org/pqh/config/WebConfigImpl.java
delete mode 100644 src/main/java/org/pqh/util/Log4jUtil.java
diff --git a/makeGif/pom.xml b/makeGif/pom.xml
new file mode 100644
index 0000000..76fd72f
--- /dev/null
+++ b/makeGif/pom.xml
@@ -0,0 +1,57 @@
+
+
+
+ webCrawler
+ org.pqh
+ 1.0
+
+ 4.0.0
+
+ makeGif
+
+
+
+ makeGif
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+ 3.6.1
+
+
+ ${java.version}
+ UTF-8
+
+
+
+
+ maven-assembly-plugin
+
+
+ jar-with-dependencies
+
+
+
+
+
+
+
+
+
+ make-assembly
+ package
+
+ single
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index d7a3e71..32aa91d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -5,17 +5,20 @@
org.pqh
webCrawler
- war
+ pom
1.0
简单的网络爬虫客户端
+
+ makeGif
+
UTF-8
UTF-8
1.8
6.0.6
- 4.3.8.RELEASE
+ RELEASE
@@ -46,7 +49,7 @@
org.hibernate
hibernate-core
- 5.2.10.Final
+ RELEASE
@@ -104,6 +107,11 @@
provided
+
+
+
+
+
@@ -125,4 +133,5 @@
+
diff --git a/src/main/java/org/pqh/config/WebConfig.java b/src/main/java/org/pqh/config/AbstractWebConfig.java
similarity index 74%
rename from src/main/java/org/pqh/config/WebConfig.java
rename to src/main/java/org/pqh/config/AbstractWebConfig.java
index 4093512..41a153b 100644
--- a/src/main/java/org/pqh/config/WebConfig.java
+++ b/src/main/java/org/pqh/config/AbstractWebConfig.java
@@ -1,16 +1,20 @@
package org.pqh.config;
+import org.apache.logging.log4j.LogManager;
import org.springframework.web.filter.CharacterEncodingFilter;
import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer;
-import javax.servlet.*;
+import javax.servlet.DispatcherType;
+import javax.servlet.FilterRegistration;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
import java.util.EnumSet;
/**
* Created by reborn on 2017/7/28.
*/
-public class WebConfig extends AbstractAnnotationConfigDispatcherServletInitializer {
+public class AbstractWebConfig extends AbstractAnnotationConfigDispatcherServletInitializer {
private String encoding ="UTF-8";
@@ -31,6 +35,7 @@ public class WebConfig extends AbstractAnnotationConfigDispatcherServletInitiali
@Override
public void onStartup(ServletContext servletContext) throws ServletException {
+ LogManager.getLogger().info("onStartup");
super.onStartup(servletContext);
FilterRegistration.Dynamic dynamic=super.registerServletFilter(servletContext,new CharacterEncodingFilter(encoding));
dynamic.addMappingForUrlPatterns(EnumSet.of(DispatcherType.REQUEST),true,"/*");
diff --git a/src/main/java/org/pqh/config/WebConfigImpl.java b/src/main/java/org/pqh/config/WebConfigImpl.java
new file mode 100644
index 0000000..1bf04f8
--- /dev/null
+++ b/src/main/java/org/pqh/config/WebConfigImpl.java
@@ -0,0 +1,36 @@
+package org.pqh.config;
+
+import org.apache.logging.log4j.LogManager;
+import org.springframework.web.WebApplicationInitializer;
+
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+
+/**
+ * Created by reborn on 2017/9/18.
+ */
+public class WebConfigImpl implements WebApplicationInitializer{
+ private String encoding ="UTF-8";
+
+ @Override
+ public void onStartup(ServletContext servletContext) throws ServletException {
+ LogManager.getLogger().info("onStartup");
+// //基于注解配置的上下文
+// AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext();
+// //注册Spring容器配置类
+// context.register(SpringConfig.class);
+// ServletRegistration.Dynamic servlet = servletContext.addServlet("dispatcher", new DispatcherServlet(context));
+// //配置映射路径
+// servlet.addMapping("/");
+// //启动顺序
+// servlet.setLoadOnStartup(1);
+//
+//
+// servletContext.addListener(new ContextLoaderListener(context));
+//
+// FilterRegistration.Dynamic characterEncodingFilter=servletContext.addFilter("CharacterEncodingFilter", CharacterEncodingFilter.class);
+// servletContext.log("CharacterEncodingFilter设置编码:"+encoding);
+// characterEncodingFilter.setInitParameter("encoding",encoding);
+// characterEncodingFilter.addMappingForUrlPatterns(EnumSet.of(DispatcherType.REQUEST),true,"/*");
+ }
+}
diff --git a/src/main/java/org/pqh/controller/AdminController.java b/src/main/java/org/pqh/controller/AdminController.java
index 18f495a..2d3fc27 100644
--- a/src/main/java/org/pqh/controller/AdminController.java
+++ b/src/main/java/org/pqh/controller/AdminController.java
@@ -1,5 +1,6 @@
package org.pqh.controller;
+import org.apache.logging.log4j.LogManager;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
@@ -7,9 +8,10 @@ import org.springframework.web.bind.annotation.RequestMapping;
* Created by reborn on 2017/9/14.
*/
@Controller
-public class AdminController {
+public class AdminController{
@RequestMapping({"","index"})
private String index(){
+ LogManager.getLogger().info("进入首页");
return "index";
}
}
diff --git a/src/main/java/org/pqh/controller/BaseController.java b/src/main/java/org/pqh/controller/BaseController.java
index e2fb7a2..3b401f2 100644
--- a/src/main/java/org/pqh/controller/BaseController.java
+++ b/src/main/java/org/pqh/controller/BaseController.java
@@ -1,5 +1,7 @@
package org.pqh.controller;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
import org.pqh.model.AbstractModel;
import org.pqh.service.BaseService;
import org.pqh.util.DBAction;
@@ -16,12 +18,15 @@ import javax.annotation.Resource;
@Controller
public class BaseController {
+ protected Logger log= LogManager.getLogger();
+
@Resource
- BaseService baseService;
+ protected BaseService baseService;
@ResponseBody
@RequestMapping(value = "{action}",produces = "text/html;charset=UTF-8")
public String curd(@PathVariable DBAction action,T model) {
+ log.info(model.tableNote()+"进行"+action+"操作请求");
return baseService.curd(action, model);
}
diff --git a/src/main/java/org/pqh/model/AbstractModel.java b/src/main/java/org/pqh/model/AbstractModel.java
index 2df4b98..18ac1ab 100644
--- a/src/main/java/org/pqh/model/AbstractModel.java
+++ b/src/main/java/org/pqh/model/AbstractModel.java
@@ -8,4 +8,6 @@ import java.io.Serializable;
public abstract class AbstractModel {
public abstract Serializable primaryKey();
+
+ public abstract String tableNote();
}
diff --git a/src/main/java/org/pqh/model/Config.java b/src/main/java/org/pqh/model/Config.java
index 69eea3d..54ae9f2 100644
--- a/src/main/java/org/pqh/model/Config.java
+++ b/src/main/java/org/pqh/model/Config.java
@@ -44,4 +44,9 @@ public class Config extends AbstractModel{
public Serializable primaryKey() {
return getJackson();
}
+
+ @Override
+ public String tableNote() {
+ return "测试表";
+ }
}
diff --git a/src/main/java/org/pqh/model/Param.java b/src/main/java/org/pqh/model/Param.java
index 52ed8a7..ade996b 100644
--- a/src/main/java/org/pqh/model/Param.java
+++ b/src/main/java/org/pqh/model/Param.java
@@ -80,4 +80,9 @@ public class Param extends AbstractModel{
public Serializable primaryKey() {
return getKey();
}
+
+ @Override
+ public String tableNote() {
+ return "系统参数表";
+ }
}
diff --git a/src/main/java/org/pqh/service/BaseService.java b/src/main/java/org/pqh/service/BaseService.java
index 05de1f1..8379a7b 100644
--- a/src/main/java/org/pqh/service/BaseService.java
+++ b/src/main/java/org/pqh/service/BaseService.java
@@ -1,5 +1,7 @@
package org.pqh.service;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
import org.pqh.dao.BaseDao;
import org.pqh.model.AbstractModel;
import org.pqh.util.DBAction;
@@ -14,6 +16,8 @@ import javax.annotation.Resource;
@Service
public class BaseService {
+ protected Logger log= LogManager.getLogger();
+
@Resource
private BaseDao baseDao;
@@ -34,7 +38,7 @@ public class BaseService {
}
return action+" success";
}catch (DataAccessException e){
-
+ log.error(formModel.tableNote()+"进行"+action+"操作失败,原因是:"+e.getMessage());
}
return action+" fail";
}
diff --git a/src/main/java/org/pqh/util/Log4jUtil.java b/src/main/java/org/pqh/util/Log4jUtil.java
deleted file mode 100644
index ee908f2..0000000
--- a/src/main/java/org/pqh/util/Log4jUtil.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package org.pqh.util;
-
-/**
- * Created by reborn on 2017/8/8.
- */
-public class Log4jUtil {
-
-}
diff --git a/src/main/webapp/WEB-INF/jsp/index.jsp b/src/main/webapp/WEB-INF/jsp/index.jsp
index dd1a45f..77cdad8 100644
--- a/src/main/webapp/WEB-INF/jsp/index.jsp
+++ b/src/main/webapp/WEB-INF/jsp/index.jsp
@@ -5,6 +5,6 @@
Title
- 简单的网络爬虫客户端
+ 首页