fanli-service-goods/pom.xml | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
fanli-service-goods/src/main/java/com/yeshi/fanli/goods/job/JobFactory.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
fanli-service-goods/src/main/resources/ehcache.xml | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
fanli-service-goods/src/main/resources/mybatis-config.xml | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
fanli-service-goods/src/main/resources/spring.xml | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
fanli-service-goods/src/main/webapps/WEB-INF/web.xml | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
fanli-service-goods/pom.xml
@@ -10,9 +10,34 @@ </parent> <modelVersion>4.0.0</modelVersion> <artifactId>goods</artifactId> <artifactId>fanli-service-goods</artifactId> <packaging>war</packaging> <build> <finalName>fanli-goods</finalName> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-war-plugin</artifactId> <configuration> <webXml>src\main\webapps\WEB-INF\web.xml</webXml> </configuration> </plugin> </plugins> </build> <dependencies> <dependency> <groupId>com.yeshi.fanli</groupId> <artifactId>fanli-common-config</artifactId> <version>1.0-SNAPSHOT</version> </dependency> <dependency> <groupId>com.yeshi.fanli</groupId> <artifactId>fanli-facade-goods</artifactId> <version>1.0-SNAPSHOT</version> </dependency> </dependencies> </project> fanli-service-goods/src/main/java/com/yeshi/fanli/goods/job/JobFactory.java
New file @@ -0,0 +1,20 @@ package com.yeshi.fanli.goods.job; import org.quartz.spi.TriggerFiredBundle; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.config.AutowireCapableBeanFactory; import org.springframework.scheduling.quartz.AdaptableJobFactory; public class JobFactory extends AdaptableJobFactory { @Autowired //这个对象Spring会帮我们自动注入进来,也属于Spring技术范畴. private AutowireCapableBeanFactory capableBeanFactory; @Override protected Object createJobInstance(TriggerFiredBundle bundle) throws Exception { // 调用父类的方法 Object jobInstance = super.createJobInstance(bundle); // 进行注入,这属于Spring的技术,不清楚的可以查看Spring的API. capableBeanFactory.autowireBean(jobInstance); return jobInstance; } } fanli-service-goods/src/main/resources/ehcache.xml
New file @@ -0,0 +1,181 @@ <?xml version="1.0" encoding="UTF-8"?> <ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://ehcache.org/ehcache.xsd"> <!--磁盘缓存的地址 --> <diskStore path="java.io.tmpdir" /> <!-- <diskStore path="D:\test" /> --> <!-- 默认缓存 --> <defaultCache maxElementsInMemory="1000" eternal="false" maxElementsOnDisk="10000" timeToIdleSeconds="120" timeToLiveSeconds="120" overflowToDisk="true" /> <!-- 分类缓存 --> <cache name="classCache" maxElementsInMemory="1000" maxElementsOnDisk="10000" eternal="false" timeToIdleSeconds="120" timeToLiveSeconds="120" overflowToDisk="true" memoryStoreEvictionPolicy="LRU" /> <!-- 今日热门 --> <cache name="crgCache" maxElementsInMemory="1000" maxElementsOnDisk="10000" eternal="false" timeToIdleSeconds="1200" timeToLiveSeconds="1200" overflowToDisk="true" memoryStoreEvictionPolicy="LRU" /> <!-- 首页banner缓存 --> <cache name="bannerCache" maxElementsInMemory="1000" maxElementsOnDisk="10000" eternal="false" timeToIdleSeconds="120" timeToLiveSeconds="120" overflowToDisk="true" memoryStoreEvictionPolicy="LRU" /> <!-- 首页版块缓存 --> <cache name="supersectionCache" maxElementsInMemory="1000" maxElementsOnDisk="10000" eternal="false" timeToIdleSeconds="120" timeToLiveSeconds="120" overflowToDisk="true" memoryStoreEvictionPolicy="LRU" /> <!-- 首页专题缓存 --> <cache name="specialCache" maxElementsInMemory="1000" maxElementsOnDisk="10000" eternal="false" timeToIdleSeconds="120" timeToLiveSeconds="120" overflowToDisk="true" memoryStoreEvictionPolicy="LRU" /> <!--版块商品缓存 --> <cache name="sectionCache" maxElementsInMemory="1000" maxElementsOnDisk="10000" eternal="false" timeToIdleSeconds="120" timeToLiveSeconds="120" overflowToDisk="true" memoryStoreEvictionPolicy="LRU" /> <!-- 客户端参数缓存 --> <cache name="clientParamCache" maxElementsInMemory="1000" maxElementsOnDisk="10000" eternal="false" timeToIdleSeconds="120" timeToLiveSeconds="120" overflowToDisk="true" memoryStoreEvictionPolicy="LRU" /> <!-- 系统参数缓存 --> <cache name="sysCache" maxElementsInMemory="1000" maxElementsOnDisk="10000" eternal="false" timeToIdleSeconds="120" timeToLiveSeconds="120" overflowToDisk="true" memoryStoreEvictionPolicy="LRU" /> <!-- 页面全部缓存 --> <cache name="SimplePageCachingFilter" maxElementsInMemory="10" maxElementsOnDisk="10" eternal="false" overflowToDisk="true" timeToIdleSeconds="240" timeToLiveSeconds="240" memoryStoreEvictionPolicy="LFU"> </cache> <cache name="maskKeyCache" maxElementsInMemory="1000" maxElementsOnDisk="10000" eternal="false" timeToIdleSeconds="180000" timeToLiveSeconds="180000" overflowToDisk="true" memoryStoreEvictionPolicy="LRU" /> <!-- 子系统缓存 --> <cache name="childSystemCache" maxElementsInMemory="1000" maxElementsOnDisk="10000" eternal="false" timeToIdleSeconds="180000" timeToLiveSeconds="180000" overflowToDisk="true" memoryStoreEvictionPolicy="LRU" /> <!--三级商品缓存 --> <cache name="goodsCache" maxElementsInMemory="1000" maxElementsOnDisk="10000" eternal="false" timeToIdleSeconds="600" timeToLiveSeconds="600" overflowToDisk="true" memoryStoreEvictionPolicy="LRU" /> <!-- 优惠商品缓存 --> <cache name="taoBaoCouponCache" maxElementsInMemory="1000" maxElementsOnDisk="10000" eternal="false" timeToIdleSeconds="3600" timeToLiveSeconds="3600" overflowToDisk="true" memoryStoreEvictionPolicy="LRU" /> <cache name="config" maxElementsInMemory="1000" maxElementsOnDisk="10000" eternal="false" timeToIdleSeconds="18000" timeToLiveSeconds="18000" overflowToDisk="true" memoryStoreEvictionPolicy="LRU" /> <cache name="configCache" maxElementsInMemory="1000" maxElementsOnDisk="10000" eternal="false" timeToIdleSeconds="120" timeToLiveSeconds="120" overflowToDisk="true" memoryStoreEvictionPolicy="LRU" /> <cache name="homeBaoManage" maxElementsInMemory="1000" maxElementsOnDisk="10000" eternal="false" timeToIdleSeconds="18000" timeToLiveSeconds="18000" overflowToDisk="true" memoryStoreEvictionPolicy="LRU" /> <cache name="temai" maxElementsInMemory="1000" maxElementsOnDisk="10000" eternal="false" timeToIdleSeconds="18000" timeToLiveSeconds="18000" overflowToDisk="true" memoryStoreEvictionPolicy="LRU" /> <!-- 淘客缓存 --> <cache name="taoKeCache" maxElementsInMemory="1000" maxElementsOnDisk="10000" eternal="false" timeToIdleSeconds="20" timeToLiveSeconds="20" overflowToDisk="true" memoryStoreEvictionPolicy="LRU" /> <!-- 动态缓存 --> <cache name="activityCache" maxElementsInMemory="1000" maxElementsOnDisk="10000" eternal="false" timeToIdleSeconds="120" timeToLiveSeconds="120" overflowToDisk="true" memoryStoreEvictionPolicy="LRU" /> <!-- dos拦截 --> <cache name="rsCache" maxElementsInMemory="1000" maxElementsOnDisk="10000" eternal="false" timeToIdleSeconds="120" timeToLiveSeconds="120" overflowToDisk="true" memoryStoreEvictionPolicy="LRU" /> <!-- 淘客推荐模块商品缓存 --> <cache name="taoKeMaterialCache" maxElementsInMemory="1000" maxElementsOnDisk="10000" eternal="false" timeToIdleSeconds="120" timeToLiveSeconds="120" overflowToDisk="true" memoryStoreEvictionPolicy="LRU" /> <!-- 淘客物料搜索缓存 --> <cache name="searchWuLiaoCache" maxElementsInMemory="1000" maxElementsOnDisk="10000" eternal="false" timeToIdleSeconds="120" timeToLiveSeconds="120" overflowToDisk="true" memoryStoreEvictionPolicy="LRU" /> <!-- 9.9/19.9/29.9/49.9模块商品缓存 --> <cache name="quality9K9Cache" maxElementsInMemory="1000" maxElementsOnDisk="10000" eternal="false" timeToIdleSeconds="120" timeToLiveSeconds="120" overflowToDisk="true" memoryStoreEvictionPolicy="LRU" /> <!-- 精选库商品查询缓存 --> <cache name="qualityCache" maxElementsInMemory="1000" maxElementsOnDisk="10000" eternal="false" timeToIdleSeconds="120" timeToLiveSeconds="120" overflowToDisk="true" memoryStoreEvictionPolicy="LRU" /> <!-- 标签缓存 --> <cache name="labelCache" maxElementsInMemory="1000" maxElementsOnDisk="10000" eternal="false" timeToIdleSeconds="120" timeToLiveSeconds="120" overflowToDisk="true" memoryStoreEvictionPolicy="LRU" /> <!-- 淘宝推荐物料id --> <cache name="taobaoMeterialCache" maxElementsInMemory="1000" maxElementsOnDisk="10000" eternal="false" timeToIdleSeconds="120" timeToLiveSeconds="120" overflowToDisk="true" memoryStoreEvictionPolicy="LRU" /> <!-- 混合分类查询缓存 --> <cache name="mergeClassCache" maxElementsInMemory="1000" maxElementsOnDisk="10000" eternal="false" timeToIdleSeconds="120" timeToLiveSeconds="120" overflowToDisk="true" memoryStoreEvictionPolicy="LRU" /> <!-- 混合分类查询缓存 --> <cache name="helpCenterCache" maxElementsInMemory="1000" maxElementsOnDisk="10000" eternal="false" timeToIdleSeconds="120" timeToLiveSeconds="120" overflowToDisk="true" memoryStoreEvictionPolicy="LRU" /> <!-- 双11缓存 --> <cache name="s11Cache" maxElementsInMemory="1000" maxElementsOnDisk="10000" eternal="false" timeToIdleSeconds="120" timeToLiveSeconds="120" overflowToDisk="true" memoryStoreEvictionPolicy="LRU" /> </ehcache> fanli-service-goods/src/main/resources/mybatis-config.xml
New file @@ -0,0 +1,25 @@ <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN" "http://mybatis.org/dtd/mybatis-3-config.dtd"> <configuration> <!-- 配置全局属性 --> <settings> <!-- 使用jdbc的getGeneratedKeys获取数据库自增主键值 --> <setting name="useGeneratedKeys" value="true" /> <!-- 使用列别名替换列名 默认:true --> <setting name="useColumnLabel" value="true" /> <!-- 开启驼峰命名转换:Table{create_time} -> Entity{createTime} --> <setting name="mapUnderscoreToCamelCase" value="true" /> <setting name="logImpl" value="STDOUT_LOGGING" /> </settings> <typeHandlers> <package name="com.yeshi.fanli.util.mybatishandler"/> </typeHandlers> </configuration> fanli-service-goods/src/main/resources/spring.xml
New file @@ -0,0 +1,234 @@ <?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:aop="http://www.springframework.org/schema/aop" xmlns:cache="http://www.springframework.org/schema/cache" xmlns:context="http://www.springframework.org/schema/context" xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:task="http://www.springframework.org/schema/task" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:mongo="http://www.springframework.org/schema/data/mongo" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.2.xsd http://www.springframework.org/schema/cache http://www.springframework.org/schema/cache/spring-cache-3.2.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-3.2.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.2.xsd http://www.springframework.org/schema/data/mongo http://www.springframework.org/schema/data/mongo/spring-mongo-1.0.xsd"> <!-- 必须采用java8 --> <!-- 组件扫描 --> <context:component-scan base-package="com.yeshi.fanli.goods"> </context:component-scan> <!--配置spring 注解 --> <context:annotation-config/> <!-- 默认的注解映射的支持 --> <mvc:annotation-driven/> <!-- Spring AOP支持 --> <aop:aspectj-autoproxy proxy-target-class="true"/> <!-- 引入配置文件 --> <context:property-placeholder location="classpath:redis.properties,classpath:druid.properties,classpath:mongo.properties"/> <bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver"/> <bean class="org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor"/> <bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource" init-method="init" destroy-method="close"> <!-- 基本属性 url、user、password --> <!-- rdsw9f61e43320loxs25.mysql.rds.aliyuncs.com --> <!-- <property name="url" value="jdbc:mysql://127.0.0.1:3306/ec_quan?useUnicode=true&characterEncoding=utf-8" /> <property name="username" value="root" /> <property name="password" value="123456" /> --> <!-- gz-cdb-r13d0yi9.sql.tencentcdb.com:62929 172.16.16.17:3306 --> <property name="url" value="${druid.url}"/> <property name="username" value="${druid.username}"/> <property name="password" value="${druid.password}"/> <!-- 配置初始化大小、最小、最大 --> <property name="initialSize" value="${druid.initialSize}"/> <property name="minIdle" value="${druid.minIdle}"/> <property name="maxActive" value="${druid.maxActive}"/> <!-- 配置获取连接等待超时的时间 --> <property name="maxWait" value="${druid.maxWait}"/> <!-- 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒 --> <property name="timeBetweenEvictionRunsMillis" value="${druid.timeBetweenEvictionRunsMillis}"/> <!-- 超过时间限制是否回收 --> <property name="removeAbandoned" value="true"/> <!-- 超时时间;单位为秒。180秒=3分钟 --> <property name="removeAbandonedTimeout" value="180"/> <!-- 配置一个连接在池中最小生存的时间,单位是毫秒 --> <property name="minEvictableIdleTimeMillis" value="${druid.minEvictableIdleTimeMillis}"/> <property name="validationQuery" value="SELECT 'x'"/> <property name="testWhileIdle" value="true"/> <property name="testOnBorrow" value="false"/> <property name="testOnReturn" value="false"/> <!-- 打开PSCache,并且指定每个连接上PSCache的大小 --> <property name="poolPreparedStatements" value="false"/> <property name="maxPoolPreparedStatementPerConnectionSize" value="20"/> <!-- 配置监控统计拦截的filters --> <property name="filters" value="stat"/> </bean> <bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean"> <property name="dataSource" ref="dataSource"></property> <property name="hibernateProperties"> <props> <prop key="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</prop> <!-- <prop key="hibernate.hbm2ddl.auto">false</prop> --> <prop key="hibernate.show_sql">true</prop> </props> </property> <property name="configLocation" value="classpath:hibernate.cfg.xml"/> <!-- 自动扫描实体 --> <property name="packagesToScan" value="com.yeshi.fanli.goods.entity"/> </bean> <!-- spring和MyBatis完美整合,不需要mybatis的配置映射文件 --> <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"> <property name="dataSource" ref="dataSource"/> <property name="configLocation" value="classpath:mybatis-config.xml"/> <!-- 自动扫描mapping.xml文件 --> <property name="mapperLocations" value="classpath:com/yeshi/fanli/goods/mapping/**/*.xml"></property> </bean> <!-- DAO接口所在包名,Spring会自动查找其下的类 --> <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer"> <property name="basePackage" value="com.yeshi.fanli.dao"/> <property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"></property> </bean> <!-- 事物 --> <bean id="transactionManager" class="org.springframework.orm.hibernate4.HibernateTransactionManager"> <property name="sessionFactory" ref="sessionFactory"/> </bean> <tx:annotation-driven transaction-manager="transactionManager" proxy-target-class="true"/> <bean id="hibernateTemplate" class="org.springframework.orm.hibernate4.HibernateTemplate"> <property name="sessionFactory" ref="sessionFactory"/> </bean> <task:annotation-driven scheduler="qbScheduler" mode="proxy"/> <task:scheduler id="qbScheduler" pool-size="50"/> <!-- 缓存注解支持 --> <cache:annotation-driven cache-manager="cacheManager"/> <bean id="cacheManagerFactory" class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean"> <property name="configLocation" value="classpath:ehcache.xml"/> </bean> <bean id="cacheManager" class="org.springframework.cache.ehcache.EhCacheCacheManager"> <property name="cacheManager" ref="cacheManagerFactory"/> </bean> <!-- redis连接池 --> <bean id="jedisConfig" class="redis.clients.jedis.JedisPoolConfig"> <property name="maxActive" value="${redis.max_active}"></property> <property name="maxIdle" value="${redis.max_idle}"></property> <property name="maxWait" value="${redis.max_wait}"></property> <property name="testOnBorrow" value="${redis.test_on_borrow}"></property> </bean> <bean id="jedisPool" class="redis.clients.jedis.JedisPool"> <constructor-arg name="poolConfig" ref="jedisConfig"></constructor-arg> <constructor-arg name="host" value="${redis.addr}"></constructor-arg> <constructor-arg name="port" value="${redis.port}"></constructor-arg> <constructor-arg name="timeout" value="${redis.timeout}"></constructor-arg> <constructor-arg name="password" value="${redis.auth}"></constructor-arg> </bean> <!-- redis连接工厂 --> <bean id="connectionFactory" class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory"> <property name="hostName" value="${redis.addr}"></property> <property name="port" value="${redis.port}"></property> <property name="password" value="${redis.auth}"></property> <property name="poolConfig" ref="jedisConfig"></property> </bean> <!-- redis操作模板,这里采用尽量面向对象的模板 --> <bean id="redisTemplate" class="org.springframework.data.redis.core.StringRedisTemplate"> <property name="connectionFactory" ref="connectionFactory"/> <property name="keySerializer"> <bean class="org.springframework.data.redis.serializer.StringRedisSerializer"/> </property> <property name="valueSerializer"> <bean class="org.springframework.data.redis.serializer.JdkSerializationRedisSerializer"/> </property> </bean> <!-- mongodb --> <mongo:mongo id="mongo" host="${mongo.host}" port="${mongo.port}"> <mongo:options connections-per-host="${mongo.connectionsPerHost}" threads-allowed-to-block-for-connection-multiplier="${mongo.threadsAllowedToBlockForConnectionMultiplier}" connect-timeout="${mongo.connectTimeout}" max-wait-time="${mongo.maxWaitTime}" auto-connect-retry="${mongo.autoConnectRetry}" socket-keep-alive="${mongo.socketKeepAlive}" socket-timeout="${mongo.socketTimeout}" slave-ok="${mongo.slaveOk}" write-number="1" write-timeout="0" write-fsync="true"/> </mongo:mongo> <bean id="mongoTemplate" class="org.springframework.data.mongodb.core.MongoTemplate"> <constructor-arg name="mongoDbFactory" ref="mongoDbFactory"/> </bean> <bean id="mongoDbFactory" class="org.springframework.data.mongodb.core.SimpleMongoDbFactory"> <constructor-arg name="mongo" ref="mongo"/> <constructor-arg name="databaseName" value="${mongo.dbname}"/> <constructor-arg name="credentials" ref="userCredentials"/> <constructor-arg name="authenticationDatabaseName" value="admin"/> </bean> <bean id="userCredentials" class="org.springframework.data.authentication.UserCredentials"> <constructor-arg name="username" value="${mongo.username}"/> <constructor-arg name="password" value="${mongo.password}"/> </bean> <bean id="jobFactory" class="com.yeshi.fanli.goods.job.JobFactory"></bean> <bean id="scheduler" name="Scheduler" lazy-init="false" class="org.springframework.scheduling.quartz.SchedulerFactoryBean"> <property name="jobFactory" ref="jobFactory"></property> </bean> <!-- Spring线程池 --> <bean id="taskExecutor" class="org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor"> <!-- 线程池维护线程的最少数量 --> <property name="corePoolSize" value="100"/> <!-- 线程池维护线程所允许的空闲时间 --> <property name="keepAliveSeconds" value="30000"/> <!-- 线程池维护线程的最大数量 --> <property name="maxPoolSize" value="1000"/> <!-- 线程池所使用的缓冲队列 --> <property name="queueCapacity" value="200"/> </bean> </beans> fanli-service-goods/src/main/webapps/WEB-INF/web.xml
New file @@ -0,0 +1,13 @@ <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5" metadata-complete="true"> <context-param> <param-name>contextConfigLocation</param-name> <param-value>classpath*:/spring.xml</param-value> </context-param> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> </web-app>