parent
09ef84211d
commit
b24f09407c
@ -1,57 +0,0 @@ |
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" |
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
||||
<parent> |
||||
<artifactId>webCrawler</artifactId> |
||||
<groupId>org.pqh</groupId> |
||||
<version>1.0</version> |
||||
</parent> |
||||
<modelVersion>4.0.0</modelVersion> |
||||
|
||||
<artifactId>makeGif</artifactId> |
||||
|
||||
<build> |
||||
|
||||
<finalName>makeGif</finalName> |
||||
|
||||
<plugins> |
||||
<plugin> |
||||
<groupId>org.apache.maven.plugins</groupId> |
||||
<artifactId>maven-compiler-plugin</artifactId> |
||||
<version>3.6.1</version> |
||||
<configuration> |
||||
<source>${java.version}</source> |
||||
<target>${java.version}</target> |
||||
<encoding>UTF-8</encoding> |
||||
</configuration> |
||||
</plugin> |
||||
|
||||
<plugin> |
||||
<artifactId>maven-assembly-plugin</artifactId> |
||||
<configuration> |
||||
<descriptorRefs> |
||||
<descriptorRef>jar-with-dependencies</descriptorRef> |
||||
</descriptorRefs> |
||||
<archive> |
||||
<manifest> |
||||
<mainClass></mainClass> |
||||
</manifest> |
||||
</archive> |
||||
</configuration> |
||||
<executions> |
||||
<execution> |
||||
<id>make-assembly</id> |
||||
<phase>package</phase> |
||||
<goals> |
||||
<goal>single</goal> |
||||
</goals> |
||||
</execution> |
||||
</executions> |
||||
</plugin> |
||||
</plugins> |
||||
|
||||
|
||||
</build> |
||||
|
||||
</project> |
@ -1,11 +0,0 @@ |
||||
package org.pqh.aop; |
||||
|
||||
import org.aspectj.lang.annotation.Pointcut; |
||||
|
||||
/** |
||||
* Created by reborn on 2017/8/3. |
||||
*/ |
||||
public class MatcherRule { |
||||
@Pointcut("execution(* org.pqh.dao.BaseDao.*(..))") |
||||
public void biliDaoRule(){} |
||||
} |
@ -1,10 +0,0 @@ |
||||
<%@ page contentType="text/html;charset=UTF-8" language="java" %> |
||||
<!DOCTYPE html> |
||||
<html lang="en"> |
||||
<head> |
||||
<title>Title</title> |
||||
</head> |
||||
<body> |
||||
<h1>首页</h1> |
||||
</body> |
||||
</html> |
@ -1,48 +0,0 @@ |
||||
import org.apache.logging.log4j.LogManager; |
||||
import org.apache.logging.log4j.Logger; |
||||
import org.apache.logging.log4j.core.LoggerContext; |
||||
import org.apache.logging.log4j.core.config.xml.XmlConfiguration; |
||||
|
||||
import java.net.URI; |
||||
import java.net.URISyntaxException; |
||||
|
||||
/** |
||||
* Created by reborn on 2017/8/3. |
||||
*/ |
||||
|
||||
public class JunitTest { |
||||
|
||||
// private static final boolean flag=init();
|
||||
private static final Logger rootLogger= LogManager.getLogger(); |
||||
private static final Logger consoleLogger= LogManager.getLogger("log1"); |
||||
private static final Logger loggerFile= LogManager.getLogger("log2"); |
||||
|
||||
public static void main(String[] args) { |
||||
|
||||
// rootLogger.info("rootLogger");
|
||||
// consoleLogger.info("consoleLogger");
|
||||
// loggerFile.info("loggerFile");
|
||||
|
||||
// Collection<org.apache.logging.log4j.core.Logger> loggers=loggerContext.getLoggers();
|
||||
// for(org.apache.logging.log4j.core.Logger logger:loggers){
|
||||
// logger.info(logger.getName());
|
||||
// }
|
||||
|
||||
|
||||
} |
||||
|
||||
|
||||
|
||||
private static boolean init(){ |
||||
System.out.println(XmlConfiguration.class.getClassLoader()); |
||||
LoggerContext loggerContext= (LoggerContext) LogManager.getContext(false); |
||||
try { |
||||
URI uri=new URI("http://42.56.70.185:8080/master/testlog.xml"); |
||||
loggerContext.setConfigLocation(uri); |
||||
} catch (URISyntaxException e) { |
||||
e.printStackTrace(); |
||||
} |
||||
return true; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,95 @@ |
||||
<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/maven-v4_0_0.xsd"> |
||||
<parent> |
||||
<artifactId>webCrawler</artifactId> |
||||
<groupId>org.pqh</groupId> |
||||
<version>1.0-SNAPSHOT</version> |
||||
</parent> |
||||
<modelVersion>4.0.0</modelVersion> |
||||
<artifactId>achieve</artifactId> |
||||
<packaging>war</packaging> |
||||
<name>achieve Maven Webapp</name> |
||||
<url>https://gitee.com/WuXianChaoPin/webCrawler</url> |
||||
<dependencies> |
||||
<dependency> |
||||
<groupId>org.pqh</groupId> |
||||
<artifactId>core</artifactId> |
||||
<version>1.0-SNAPSHOT</version> |
||||
</dependency> |
||||
|
||||
<dependency> |
||||
<groupId>org.springframework</groupId> |
||||
<artifactId>spring-web</artifactId> |
||||
</dependency> |
||||
|
||||
<dependency> |
||||
<groupId>org.springframework</groupId> |
||||
<artifactId>spring-webmvc</artifactId> |
||||
</dependency> |
||||
|
||||
<dependency> |
||||
<groupId>org.springframework</groupId> |
||||
<artifactId>spring-orm</artifactId> |
||||
</dependency> |
||||
|
||||
<dependency> |
||||
<groupId>org.apache.commons</groupId> |
||||
<artifactId>commons-dbcp2</artifactId> |
||||
</dependency> |
||||
|
||||
<dependency> |
||||
<groupId>org.hibernate</groupId> |
||||
<artifactId>hibernate-core</artifactId> |
||||
</dependency> |
||||
|
||||
<dependency> |
||||
<groupId>mysql</groupId> |
||||
<artifactId>mysql-connector-java</artifactId> |
||||
</dependency> |
||||
|
||||
<dependency> |
||||
<groupId>com.fasterxml.jackson.core</groupId> |
||||
<artifactId>jackson-databind</artifactId> |
||||
</dependency> |
||||
|
||||
<dependency> |
||||
<groupId>org.aspectj</groupId> |
||||
<artifactId>aspectjweaver</artifactId> |
||||
</dependency> |
||||
|
||||
<dependency> |
||||
<groupId>org.apache.logging.log4j</groupId> |
||||
<artifactId>log4j-api</artifactId> |
||||
</dependency> |
||||
|
||||
<dependency> |
||||
<groupId>org.apache.logging.log4j</groupId> |
||||
<artifactId>log4j-core</artifactId> |
||||
</dependency> |
||||
|
||||
<dependency> |
||||
<groupId>org.apache.logging.log4j</groupId> |
||||
<artifactId>log4j-web</artifactId> |
||||
</dependency> |
||||
|
||||
<dependency> |
||||
<groupId>commons-io</groupId> |
||||
<artifactId>commons-io</artifactId> |
||||
</dependency> |
||||
|
||||
<dependency> |
||||
<groupId>javax.servlet</groupId> |
||||
<artifactId>javax.servlet-api</artifactId> |
||||
<scope>provided</scope> |
||||
</dependency> |
||||
|
||||
<dependency> |
||||
<groupId>junit</groupId> |
||||
<artifactId>junit</artifactId> |
||||
<scope>test</scope> |
||||
</dependency> |
||||
</dependencies> |
||||
<build> |
||||
<finalName>achieve</finalName> |
||||
</build> |
||||
</project> |
@ -1,4 +1,4 @@ |
||||
package org.pqh.config; |
||||
package org.pqh.achieve.config; |
||||
|
||||
import org.apache.logging.log4j.LogManager; |
||||
import org.springframework.web.filter.CharacterEncodingFilter; |
@ -1,5 +1,6 @@ |
||||
package org.pqh.config; |
||||
package org.pqh.achieve.config; |
||||
|
||||
import org.pqh.core.config.HibernateConfig; |
||||
import org.springframework.context.ApplicationContext; |
||||
import org.springframework.context.annotation.*; |
||||
import org.springframework.web.servlet.config.annotation.EnableWebMvc; |
@ -1,4 +1,4 @@ |
||||
package org.pqh.config; |
||||
package org.pqh.achieve.config; |
||||
|
||||
import org.apache.logging.log4j.LogManager; |
||||
import org.springframework.web.WebApplicationInitializer; |
@ -0,0 +1,9 @@ |
||||
package org.pqh.achieve.config; |
||||
|
||||
import org.pqh.core.annotation.EnableWebCrawlerConfiguration; |
||||
import org.springframework.context.annotation.Configuration; |
||||
|
||||
@Configuration |
||||
@EnableWebCrawlerConfiguration |
||||
public class WebCrawlerConfig { |
||||
} |
@ -1,4 +1,4 @@ |
||||
package org.pqh.controller; |
||||
package org.pqh.achieve.controller; |
||||
|
||||
import org.apache.logging.log4j.LogManager; |
||||
import org.springframework.stereotype.Controller; |
@ -1,10 +1,10 @@ |
||||
package org.pqh.controller; |
||||
package org.pqh.achieve.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; |
||||
import org.pqh.core.model.AbstractModel; |
||||
import org.pqh.core.service.BaseService; |
||||
import org.pqh.core.util.DBAction; |
||||
import org.springframework.stereotype.Controller; |
||||
import org.springframework.web.bind.annotation.PathVariable; |
||||
import org.springframework.web.bind.annotation.RequestMapping; |
@ -1,6 +1,6 @@ |
||||
package org.pqh.controller; |
||||
package org.pqh.achieve.controller; |
||||
|
||||
import org.pqh.model.Config; |
||||
import org.pqh.core.model.Config; |
||||
import org.springframework.stereotype.Controller; |
||||
import org.springframework.web.bind.annotation.RequestMapping; |
||||
|
@ -1,6 +1,6 @@ |
||||
package org.pqh.controller; |
||||
package org.pqh.achieve.controller; |
||||
|
||||
import org.pqh.model.Param; |
||||
import org.pqh.core.model.Param; |
||||
import org.springframework.stereotype.Controller; |
||||
import org.springframework.web.bind.annotation.RequestMapping; |
||||
|
@ -0,0 +1,6 @@ |
||||
#dbcp2.url=jdbc:mysql://localhost:3306/bilibili?serverTimezone=UTC&&useSSL=true |
||||
#dbcp2.username=root |
||||
#dbcp2.password=123456 |
||||
dbcp2.url=jdbc:mysql://172.16.0.50:3306/bb?serverTimezone=UTC&&useSSL=true |
||||
dbcp2.username=root |
||||
dbcp2.password=123456 |
@ -0,0 +1,5 @@ |
||||
<html> |
||||
<body> |
||||
<h2>Hello World!</h2> |
||||
</body> |
||||
</html> |
@ -0,0 +1,91 @@ |
||||
<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/maven-v4_0_0.xsd"> |
||||
<parent> |
||||
<artifactId>webCrawler</artifactId> |
||||
<groupId>org.pqh</groupId> |
||||
<version>1.0-SNAPSHOT</version> |
||||
</parent> |
||||
<modelVersion>4.0.0</modelVersion> |
||||
<artifactId>core</artifactId> |
||||
<packaging>jar</packaging> |
||||
<name>core Maven Webapp</name> |
||||
<url>https://gitee.com/WuXianChaoPin/webCrawler</url> |
||||
|
||||
<dependencies> |
||||
|
||||
<dependency> |
||||
<groupId>org.springframework</groupId> |
||||
<artifactId>spring-web</artifactId> |
||||
</dependency> |
||||
|
||||
<dependency> |
||||
<groupId>org.springframework</groupId> |
||||
<artifactId>spring-webmvc</artifactId> |
||||
</dependency> |
||||
|
||||
<dependency> |
||||
<groupId>org.springframework</groupId> |
||||
<artifactId>spring-orm</artifactId> |
||||
</dependency> |
||||
|
||||
<dependency> |
||||
<groupId>org.apache.commons</groupId> |
||||
<artifactId>commons-dbcp2</artifactId> |
||||
</dependency> |
||||
|
||||
<dependency> |
||||
<groupId>org.hibernate</groupId> |
||||
<artifactId>hibernate-core</artifactId> |
||||
</dependency> |
||||
|
||||
<dependency> |
||||
<groupId>mysql</groupId> |
||||
<artifactId>mysql-connector-java</artifactId> |
||||
</dependency> |
||||
|
||||
<dependency> |
||||
<groupId>com.fasterxml.jackson.core</groupId> |
||||
<artifactId>jackson-databind</artifactId> |
||||
</dependency> |
||||
|
||||
<dependency> |
||||
<groupId>org.aspectj</groupId> |
||||
<artifactId>aspectjweaver</artifactId> |
||||
</dependency> |
||||
|
||||
<dependency> |
||||
<groupId>org.apache.logging.log4j</groupId> |
||||
<artifactId>log4j-api</artifactId> |
||||
</dependency> |
||||
|
||||
<dependency> |
||||
<groupId>org.apache.logging.log4j</groupId> |
||||
<artifactId>log4j-core</artifactId> |
||||
</dependency> |
||||
|
||||
<dependency> |
||||
<groupId>org.apache.logging.log4j</groupId> |
||||
<artifactId>log4j-web</artifactId> |
||||
</dependency> |
||||
|
||||
<dependency> |
||||
<groupId>commons-io</groupId> |
||||
<artifactId>commons-io</artifactId> |
||||
</dependency> |
||||
|
||||
<dependency> |
||||
<groupId>javax.servlet</groupId> |
||||
<artifactId>javax.servlet-api</artifactId> |
||||
<scope>provided</scope> |
||||
</dependency> |
||||
|
||||
<dependency> |
||||
<groupId>junit</groupId> |
||||
<artifactId>junit</artifactId> |
||||
<scope>test</scope> |
||||
</dependency> |
||||
</dependencies> |
||||
<build> |
||||
<finalName>core</finalName> |
||||
</build> |
||||
</project> |
@ -0,0 +1,17 @@ |
||||
package org.pqh.core.annotation; |
||||
|
||||
import org.springframework.context.annotation.ComponentScan; |
||||
import org.springframework.context.annotation.Configuration; |
||||
|
||||
import java.lang.annotation.*; |
||||
|
||||
/** |
||||
* 爬虫注入组件 |
||||
*/ |
||||
@Retention(RetentionPolicy.RUNTIME) |
||||
@Target({ElementType.TYPE}) |
||||
@Documented |
||||
@Configuration |
||||
@ComponentScan("org.pqh.core.*") |
||||
public @interface EnableWebCrawlerConfiguration { |
||||
} |
@ -1,4 +1,4 @@ |
||||
package org.pqh.aop; |
||||
package org.pqh.core.aop; |
||||
|
||||
import org.springframework.aop.MethodBeforeAdvice; |
||||
|
@ -1,6 +1,6 @@ |
||||
package org.pqh.aop; |
||||
package org.pqh.core.aop; |
||||
|
||||
import org.pqh.dao.BaseDao; |
||||
import org.pqh.core.dao.BaseDao; |
||||
import org.springframework.aop.support.StaticMethodMatcherPointcutAdvisor; |
||||
|
||||
import java.lang.reflect.Method; |
@ -0,0 +1,12 @@ |
||||
package org.pqh.core.aop; |
||||
|
||||
import org.aspectj.lang.annotation.Pointcut; |
||||
|
||||
/** |
||||
* Created by reborn on 2017/8/3. |
||||
*/ |
||||
public class MatcherRule { |
||||
@Pointcut("execution(* org.pqh.core.dao.BaseDao.*(..))") |
||||
public void biliDaoRule() { |
||||
} |
||||
} |
@ -1,6 +1,6 @@ |
||||
package org.pqh.dao; |
||||
package org.pqh.core.dao; |
||||
|
||||
import org.pqh.model.AbstractModel; |
||||
import org.pqh.core.model.AbstractModel; |
||||
import org.springframework.dao.DataAccessException; |
||||
import org.springframework.orm.hibernate5.HibernateTemplate; |
||||
import org.springframework.stereotype.Repository; |
@ -1,4 +1,4 @@ |
||||
package org.pqh.model; |
||||
package org.pqh.core.model; |
||||
|
||||
import java.io.Serializable; |
||||
|
@ -1,4 +1,4 @@ |
||||
package org.pqh.model; |
||||
package org.pqh.core.model; |
||||
|
||||
import javax.persistence.Column; |
||||
import javax.persistence.Entity; |
@ -1,4 +1,4 @@ |
||||
package org.pqh.model; |
||||
package org.pqh.core.model; |
||||
|
||||
import javax.persistence.Basic; |
||||
import javax.persistence.Column; |
@ -1,4 +1,4 @@ |
||||
package org.pqh.util; |
||||
package org.pqh.core.util; |
||||
|
||||
/** |
||||
* Created by reborn on 2017/8/2. |
@ -0,0 +1,47 @@ |
||||
package org.pqh.core.util; |
||||
|
||||
import java.io.BufferedInputStream; |
||||
import java.util.Properties; |
||||
|
||||
/** |
||||
* Properties工具类 |
||||
*/ |
||||
public final class PropertiesUtil { |
||||
// protected static final Logger log = LoggerFactory.getLogger(PropertiesUtil.class);
|
||||
|
||||
private PropertiesUtil() { |
||||
|
||||
} |
||||
|
||||
/** |
||||
* 根据资源文件名,和name获取对应的value,如果没有对应的值,将返回null |
||||
* |
||||
* @param resourceFile 资源文件名 |
||||
* @param name 对应的value |
||||
* @return 对应的值 |
||||
*/ |
||||
public static String getValue(String resourceFile, String name) { |
||||
if (resourceFile == null || name == null) { |
||||
return null; |
||||
} |
||||
return loadPropertiesFromResourceFile(resourceFile).getProperty(name); |
||||
} |
||||
|
||||
/** |
||||
* 根据资源文件路径,读取资源文件,如果资源文件不存在,将返回默认的[new Properties()] |
||||
* |
||||
* @param resourceFile 资源文件名 |
||||
* @return 资源文件 |
||||
*/ |
||||
public static Properties loadPropertiesFromResourceFile(String resourceFile) { |
||||
Properties properties = new Properties(); |
||||
try (BufferedInputStream bis = new BufferedInputStream( |
||||
PropertiesUtil.class.getClassLoader().getResourceAsStream(resourceFile))) { |
||||
properties.load(bis); |
||||
return properties; |
||||
} catch (Exception e) { |
||||
// log.error(e.getMessage(), e);
|
||||
} |
||||
return properties; |
||||
} |
||||
} |
Loading…
Reference in new issue