diff --git a/webCrawler-core/pom.xml b/core/pom.xml similarity index 96% rename from webCrawler-core/pom.xml rename to core/pom.xml index 3629462..f87a660 100644 --- a/webCrawler-core/pom.xml +++ b/core/pom.xml @@ -1,7 +1,7 @@ - webCrawler + webcrawler org.pqh 1.0-SNAPSHOT @@ -9,7 +9,7 @@ core jar core Maven Webapp - https://gitee.com/WuXianChaoPin/webCrawler + https://gitee.com/WuXianChaoPin/webcrawler diff --git a/webCrawler-core/src/main/java/org/pqh/core/annotation/EnableWebCrawlerConfiguration.java b/core/src/main/java/org/pqh/core/annotation/EnableWebCrawlerConfiguration.java similarity index 100% rename from webCrawler-core/src/main/java/org/pqh/core/annotation/EnableWebCrawlerConfiguration.java rename to core/src/main/java/org/pqh/core/annotation/EnableWebCrawlerConfiguration.java diff --git a/webCrawler-core/src/main/java/org/pqh/core/aop/InsertAdvice.java b/core/src/main/java/org/pqh/core/aop/InsertAdvice.java similarity index 100% rename from webCrawler-core/src/main/java/org/pqh/core/aop/InsertAdvice.java rename to core/src/main/java/org/pqh/core/aop/InsertAdvice.java diff --git a/webCrawler-core/src/main/java/org/pqh/core/aop/InsertAdvisor.java b/core/src/main/java/org/pqh/core/aop/InsertAdvisor.java similarity index 100% rename from webCrawler-core/src/main/java/org/pqh/core/aop/InsertAdvisor.java rename to core/src/main/java/org/pqh/core/aop/InsertAdvisor.java diff --git a/webCrawler-core/src/main/java/org/pqh/core/aop/LogAspect.java b/core/src/main/java/org/pqh/core/aop/LogAspect.java similarity index 100% rename from webCrawler-core/src/main/java/org/pqh/core/aop/LogAspect.java rename to core/src/main/java/org/pqh/core/aop/LogAspect.java diff --git a/webCrawler-core/src/main/java/org/pqh/core/aop/MatcherRule.java b/core/src/main/java/org/pqh/core/aop/MatcherRule.java similarity index 100% rename from webCrawler-core/src/main/java/org/pqh/core/aop/MatcherRule.java rename to core/src/main/java/org/pqh/core/aop/MatcherRule.java diff --git a/webCrawler-core/src/main/java/org/pqh/core/config/HibernateConfig.java b/core/src/main/java/org/pqh/core/config/HibernateConfig.java similarity index 79% rename from webCrawler-core/src/main/java/org/pqh/core/config/HibernateConfig.java rename to core/src/main/java/org/pqh/core/config/HibernateConfig.java index 5a31c4d..bd115b2 100644 --- a/webCrawler-core/src/main/java/org/pqh/core/config/HibernateConfig.java +++ b/core/src/main/java/org/pqh/core/config/HibernateConfig.java @@ -1,9 +1,13 @@ package org.pqh.core.config; import org.apache.commons.dbcp2.BasicDataSource; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.pqh.core.util.PropertiesUtil; +import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.PropertySource; import org.springframework.orm.hibernate5.HibernateTemplate; import org.springframework.orm.hibernate5.HibernateTransactionManager; import org.springframework.orm.hibernate5.LocalSessionFactoryBean; @@ -16,19 +20,24 @@ import java.util.Properties; * Created by reborn on 2017/7/28. */ @Configuration +@PropertySource("classpath:config.properties") @EnableTransactionManagement public class HibernateConfig { private LocalSessionFactoryBean sessionFactoryBean; private BasicDataSource dataSource; - Properties properties = PropertiesUtil.loadPropertiesFromResourceFile("config.properties"); + private Logger log= LogManager.getLogger(); + + @Value("${dbcp2.url}") + private String url; + @Value("${dbcp2.username}") + private String username; + @Value("${dbcp2.password}") + private String password; public HibernateConfig() { + log.info("数据库配置初始化\ndburl="+url+",dbcp2.username="+username+",dbcp2.password="+password); dataSource = new BasicDataSource(); - dataSource.setUrl(properties.getProperty("dbcp2.url")); - dataSource.setUsername(properties.getProperty("dbcp2.username")); - dataSource.setPassword(properties.getProperty("dbcp2.password")); - dataSource.setDriverClassName("com.mysql.cj.jdbc.Driver"); sessionFactoryBean = new LocalSessionFactoryBean(); sessionFactoryBean.setDataSource(dataSource); diff --git a/webCrawler-core/src/main/java/org/pqh/core/dao/BaseDao.java b/core/src/main/java/org/pqh/core/dao/BaseDao.java similarity index 100% rename from webCrawler-core/src/main/java/org/pqh/core/dao/BaseDao.java rename to core/src/main/java/org/pqh/core/dao/BaseDao.java diff --git a/webCrawler-core/src/main/java/org/pqh/core/model/AbstractModel.java b/core/src/main/java/org/pqh/core/model/AbstractModel.java similarity index 100% rename from webCrawler-core/src/main/java/org/pqh/core/model/AbstractModel.java rename to core/src/main/java/org/pqh/core/model/AbstractModel.java diff --git a/webCrawler-core/src/main/java/org/pqh/core/model/Config.java b/core/src/main/java/org/pqh/core/model/Config.java similarity index 100% rename from webCrawler-core/src/main/java/org/pqh/core/model/Config.java rename to core/src/main/java/org/pqh/core/model/Config.java diff --git a/webCrawler-core/src/main/java/org/pqh/core/model/Param.java b/core/src/main/java/org/pqh/core/model/Param.java similarity index 100% rename from webCrawler-core/src/main/java/org/pqh/core/model/Param.java rename to core/src/main/java/org/pqh/core/model/Param.java diff --git a/webCrawler-core/src/main/java/org/pqh/core/service/BaseService.java b/core/src/main/java/org/pqh/core/service/BaseService.java similarity index 100% rename from webCrawler-core/src/main/java/org/pqh/core/service/BaseService.java rename to core/src/main/java/org/pqh/core/service/BaseService.java diff --git a/webCrawler-core/src/main/java/org/pqh/core/util/DBAction.java b/core/src/main/java/org/pqh/core/util/DBAction.java similarity index 100% rename from webCrawler-core/src/main/java/org/pqh/core/util/DBAction.java rename to core/src/main/java/org/pqh/core/util/DBAction.java diff --git a/webCrawler-core/src/main/java/org/pqh/core/util/PropertiesUtil.java b/core/src/main/java/org/pqh/core/util/PropertiesUtil.java similarity index 100% rename from webCrawler-core/src/main/java/org/pqh/core/util/PropertiesUtil.java rename to core/src/main/java/org/pqh/core/util/PropertiesUtil.java diff --git a/pom.xml b/pom.xml index cf4fdce..51f6110 100644 --- a/pom.xml +++ b/pom.xml @@ -2,15 +2,15 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> 4.0.0 org.pqh - webCrawler + webcrawler pom 1.0-SNAPSHOT - webCrawler-core - webCrawler-achieve + core + web - webCrawler Maven Webapp - https://gitee.com/WuXianChaoPin/webCrawler + webcrawler Maven Webapp + https://gitee.com/WuXianChaoPin/webcrawler UTF-8 @@ -120,7 +120,7 @@ - webCrawler + webcrawler maven-war-plugin diff --git a/webCrawler-achieve/pom.xml b/web/pom.xml similarity index 88% rename from webCrawler-achieve/pom.xml rename to web/pom.xml index a558249..8096613 100644 --- a/webCrawler-achieve/pom.xml +++ b/web/pom.xml @@ -1,15 +1,15 @@ - webCrawler + webcrawler org.pqh 1.0-SNAPSHOT 4.0.0 - achieve + web war achieve Maven Webapp - https://gitee.com/WuXianChaoPin/webCrawler + https://gitee.com/WuXianChaoPin/webcrawler org.pqh @@ -88,8 +88,13 @@ junit test + + org.pqh + core + 1.0-SNAPSHOT + - achieve + web diff --git a/webCrawler-achieve/src/main/java/org/pqh/achieve/config/AbstractWebConfig.java b/web/src/main/java/org/pqh/achieve/config/AbstractWebConfig.java similarity index 100% rename from webCrawler-achieve/src/main/java/org/pqh/achieve/config/AbstractWebConfig.java rename to web/src/main/java/org/pqh/achieve/config/AbstractWebConfig.java diff --git a/webCrawler-achieve/src/main/java/org/pqh/achieve/config/SpringConfig.java b/web/src/main/java/org/pqh/achieve/config/SpringConfig.java similarity index 91% rename from webCrawler-achieve/src/main/java/org/pqh/achieve/config/SpringConfig.java rename to web/src/main/java/org/pqh/achieve/config/SpringConfig.java index e953d17..cce12fb 100644 --- a/webCrawler-achieve/src/main/java/org/pqh/achieve/config/SpringConfig.java +++ b/web/src/main/java/org/pqh/achieve/config/SpringConfig.java @@ -1,5 +1,6 @@ package org.pqh.achieve.config; +import org.pqh.core.annotation.EnableWebCrawlerConfiguration; import org.pqh.core.config.HibernateConfig; import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.*; @@ -12,9 +13,8 @@ import org.springframework.web.servlet.view.InternalResourceViewResolver; */ @Configuration @EnableWebMvc -@ComponentScan(basePackages = "org.pqh") @EnableAspectJAutoProxy -@Import(HibernateConfig.class) +@Import({HibernateConfig.class,WebCrawlerConfig.class}) public class SpringConfig extends WebMvcConfigurationSupport{ private static ApplicationContext applicationContext; diff --git a/webCrawler-achieve/src/main/java/org/pqh/achieve/config/WebConfigImpl.java b/web/src/main/java/org/pqh/achieve/config/WebConfigImpl.java similarity index 100% rename from webCrawler-achieve/src/main/java/org/pqh/achieve/config/WebConfigImpl.java rename to web/src/main/java/org/pqh/achieve/config/WebConfigImpl.java diff --git a/webCrawler-achieve/src/main/java/org/pqh/achieve/config/WebCrawlerConfig.java b/web/src/main/java/org/pqh/achieve/config/WebCrawlerConfig.java similarity index 100% rename from webCrawler-achieve/src/main/java/org/pqh/achieve/config/WebCrawlerConfig.java rename to web/src/main/java/org/pqh/achieve/config/WebCrawlerConfig.java diff --git a/webCrawler-achieve/src/main/java/org/pqh/achieve/controller/AdminController.java b/web/src/main/java/org/pqh/achieve/controller/AdminController.java similarity index 100% rename from webCrawler-achieve/src/main/java/org/pqh/achieve/controller/AdminController.java rename to web/src/main/java/org/pqh/achieve/controller/AdminController.java diff --git a/webCrawler-achieve/src/main/java/org/pqh/achieve/controller/BaseController.java b/web/src/main/java/org/pqh/achieve/controller/BaseController.java similarity index 100% rename from webCrawler-achieve/src/main/java/org/pqh/achieve/controller/BaseController.java rename to web/src/main/java/org/pqh/achieve/controller/BaseController.java diff --git a/webCrawler-achieve/src/main/java/org/pqh/achieve/controller/ConfigController.java b/web/src/main/java/org/pqh/achieve/controller/ConfigController.java similarity index 100% rename from webCrawler-achieve/src/main/java/org/pqh/achieve/controller/ConfigController.java rename to web/src/main/java/org/pqh/achieve/controller/ConfigController.java diff --git a/webCrawler-achieve/src/main/java/org/pqh/achieve/controller/ParamController.java b/web/src/main/java/org/pqh/achieve/controller/ParamController.java similarity index 100% rename from webCrawler-achieve/src/main/java/org/pqh/achieve/controller/ParamController.java rename to web/src/main/java/org/pqh/achieve/controller/ParamController.java diff --git a/webCrawler-achieve/src/main/resources/config.properties b/web/src/main/resources/config.properties similarity index 59% rename from webCrawler-achieve/src/main/resources/config.properties rename to web/src/main/resources/config.properties index 078e3ae..1f3aea4 100644 --- a/webCrawler-achieve/src/main/resources/config.properties +++ b/web/src/main/resources/config.properties @@ -1,6 +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.url=jdbc:mysql://localhost:3306/bilibili?serverTimezone=UTC&&useSSL=true dbcp2.username=root dbcp2.password=123456 \ No newline at end of file diff --git a/webCrawler-achieve/src/main/resources/log4j2.xml b/web/src/main/resources/log4j2.xml similarity index 100% rename from webCrawler-achieve/src/main/resources/log4j2.xml rename to web/src/main/resources/log4j2.xml diff --git a/webCrawler-achieve/src/main/webapp/WEB-INF/jsp/index.jsp b/web/src/main/webapp/WEB-INF/jsp/index.jsp similarity index 100% rename from webCrawler-achieve/src/main/webapp/WEB-INF/jsp/index.jsp rename to web/src/main/webapp/WEB-INF/jsp/index.jsp