频道栏目
首页 > 程序开发 > 软件开发 > 其他 > 正文
spring
2016-10-20 09:16:00      个评论    来源:chengpeng2014的博客  
收藏   我要投稿
### set log levels ###
log4j.rootLogger = INFO , C , timer , main , receive

### console ###
log4j.appender.C = org.apache.log4j.ConsoleAppender
log4j.appender.C.Target = System.out
log4j.appender.C.layout = org.apache.log4j.PatternLayout
log4j.appender.C.layout.ConversionPattern = [test-console][%p] [%-d{yyyy-MM-dd HH:mm:ss}] %C.%M(%L) | %m%n

### log file ###
log4j.logger.main=INFO, main  
log4j.appender.main=org.apache.log4j.DailyRollingFileAppender  
log4j.appender.main.Append=true  
log4j.appender.main.DatePattern='.'yyyy-MM-dd  
log4j.appender.main.File=../logs/main.log  
log4j.appender.main.Threshold=INFO  
log4j.appender.main.layout=org.apache.log4j.PatternLayout  
log4j.appender.main.layout.ConversionPattern=[test-main][%p] [%-d{yyyy-MM-dd HH:mm:ss}] %C.%M(%L) | %m%n
log4j.additivity.main=false  

# receive thread log
log4j.logger.receive=INFO, receive  
log4j.appender.receive=org.apache.log4j.DailyRollingFileAppender  
log4j.appender.receive.Append=true  
log4j.appender.receive.DatePattern='.'yyyy-MM-dd  
log4j.appender.receive.File=../logs/receive/receive.log  
log4j.appender.receive.Threshold=INFO  
log4j.appender.receive.layout=org.apache.log4j.PatternLayout  
log4j.appender.receive.layout.ConversionPattern=[test-receive][%p] [%-d{yyyy-MM-dd HH:mm:ss}] %C.%M(%L) | %m%n
log4j.additivity.receive=false  

# timer thread log
log4j.logger.timer=INFO, timer  
log4j.appender.timer=org.apache.log4j.DailyRollingFileAppender  
log4j.appender.timer.Append=true  
log4j.appender.timer.DatePattern='.'yyyy-MM-dd  
log4j.appender.timer.File=../logs/timer.log  
log4j.appender.timer.Threshold=INFO  
log4j.appender.timer.layout=org.apache.log4j.PatternLayout  
log4j.appender.timer.layout.ConversionPattern=[test-timer][%p] [%-d{yyyy-MM-dd HH:mm:ss}] %C.%M(%L) | %m%n
log4j.additivity.timer=false  

 

 

<?xml version="1.0" encoding="UTF-8"?>  
<beans xmlns="https://www.springframework.org/schema/beans"  
    xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance" xmlns:context="https://www.springframework.org/schema/context"  
    xsi:schemaLocation="https://www.springframework.org/schema/beans  
            https://www.springframework.org/schema/beans/spring-beans-4.1.xsd  
            https://www.springframework.org/schema/context  
            https://www.springframework.org/schema/context/spring-context-4.1.xsd">  
  
    <!--引入配置属性文件 -->  
    <context:property-placeholder location="classpath:db.properties" />  
  
    <!--自动扫描注解将其注入为bean-->  
    <context:component-scan base-package="com.test" />  
      
</beans>

 

 

<?xml version="1.0" encoding="UTF-8"?>  
<beans xmlns="https://www.springframework.org/schema/beans"  
    xmlns:mvc="https://www.springframework.org/schema/mvc" xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance"  
    xmlns:p="https://www.springframework.org/schema/p" xmlns:context="https://www.springframework.org/schema/context"  
    xsi:schemaLocation="https://www.springframework.org/schema/beans   
        https://www.springframework.org/schema/beans/spring-beans-4.1.xsd   
        https://www.springframework.org/schema/context   
        https://www.springframework.org/schema/context/spring-context-4.1.xsd   
        https://www.springframework.org/schema/mvc   
        https://www.springframework.org/schema/mvc/spring-mvc-4.1.xsd">  
  
    <!-- 自动扫描controller包下的所有类,如果@Controller注入为bean -->  
    <context:component-scan base-package="com.test.controller" />  
      
    <!-- 避免IE执行AJAX时,返回JSON出现下载文件 -->  
    <bean id="mappingJacksonHttpMessageConverter"  
        class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter">  
        <property name="supportedMediaTypes">  
            <list>  
                <value>text/html;charset=UTF-8</value>  
            </list>  
        </property>  
    </bean>  
  
    <!-- 启动Spring MVC的注解功能,完成请求和注解POJO的映射 -->  
    <bean  
        class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">  
        <property name="messageConverters">  
            <list>  
                <!-- json转换器 -->  
                <ref bean="mappingJacksonHttpMessageConverter" />  
            </list>  
        </property>  
    </bean>  
  
    <!-- 对模型视图名称的解析,即在模型视图名称添加前后缀 -->  
    <bean  
        class="org.springframework.web.servlet.view.InternalResourceViewResolver">  
        <property name="viewClass"  
            value="org.springframework.web.servlet.view.JstlView" />  
        <property name="prefix" value="/WEB-INF/views/" />  
        <property name="suffix" value=".jsp" />  
    </bean>  
  
    <!-- 配置多文件上传 -->  
    <bean id="multipartResolver"  
        class="org.springframework.web.multipart.commons.CommonsMultipartResolver">  
        <property name="defaultEncoding">  
            <value>UTF-8</value>  
        </property>  
        <property name="maxUploadSize">  
            <!-- 上传文件大小限制为31M,31*1024*1024 -->  
            <value>32505856</value>  
        </property>  
        <property name="maxInMemorySize">  
            <value>4096</value>  
        </property>  
    </bean>  
  
</beans> 


<?xml version="1.0" encoding="UTF-8"?>  
<beans xmlns="https://www.springframework.org/schema/beans"  
    xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance" xmlns:tx="https://www.springframework.org/schema/tx"  
    xmlns:aop="https://www.springframework.org/schema/aop"  
    xsi:schemaLocation="  
        https://www.springframework.org/schema/beans   
        https://www.springframework.org/schema/beans/spring-beans-4.1.xsd   
        https://www.springframework.org/schema/tx   
        https://www.springframework.org/schema/tx/spring-tx-4.1.xsd  
        https://www.springframework.org/schema/aop   
        https://www.springframework.org/schema/aop/spring-aop-4.1.xsd  
        ">  
  
    <!-- c3p0连接池配置 -->    
     <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">  
            <!-- 数据库密码 -->  
            <property name="properties">      
                <bean class="com.test.utils.C3P0DatasourcePropertiesFactory" factory-method="getProperties">    
                    <constructor-arg type="java.lang.String">    
                        <value>${jdbc.password}</value>    
                    </constructor-arg>    
                    <!-- 生产环境模式 ,才特殊处理加密密码-->      
                    <constructor-arg type="java.lang.String">    
                        <value>${jdbc.password.encrypted}</value>    
                    </constructor-arg>    
                </bean>    
            </property>    
              
          <!-- 用户名-->    
          <property name="user" value="${jdbc.username}"/>    
          <property name="driverClass" value="${jdbc.driver_class}"/>    
          <property name="jdbcUrl" value="${jdbc.url}"/>    
          <!--连接池中保留的最大连接数。默认值: 15 -->     
          <property name="maxPoolSize" value="20"/>    
          <!-- 连接池中保留的最小连接数,默认为:3-->    
          <property name="minPoolSize" value="2"/>    
          <!-- 初始化连接池中的连接数,取值应在minPoolSize与maxPoolSize之间,默认为3-->    
          <property name="initialPoolSize" value="2"/>    
          <!--最大空闲时间,60秒内未使用则连接被丢弃。若为0则永不丢弃。默认值: 0 -->     
          <property name="maxIdleTime" value="60" />  
          <!-- 当连接池连接耗尽时,客户端调用getConnection()后等待获取新连接的时间,超时后将抛出SQLException,如设为0则无限期等待。单位毫秒。默认: 0 -->     
          <property name="checkoutTimeout" value="3000"/>    
          <!--当连接池中的连接耗尽的时候c3p0一次同时获取的连接数。默认值: 3 -->     
          <property name="acquireIncrement" value="2"/>    
          <!--定义在从数据库获取新连接失败后重复尝试的次数。默认值: 30 ;小于等于0表示无限次-->     
          <property name="acquireRetryAttempts" value="0"/>    
          <!--重新尝试的时间间隔,默认为:1000毫秒-->     
          <property name="acquireRetryDelay" value="1000" />    
     </bean>  
  
    <!-- myBatis文件 -->  
    <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">  
        <property name="dataSource" ref="dataSource" />  
        <!-- mapper文件扫描 -->  
        <property name="mapperLocations" value="classpath:com/test/mapping/*.xml" />  
    </bean>  
  
    <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">  
        <property name="basePackage" value="com.test.dao" />  
        <property name="sqlSessionFactoryBeanName" value="sqlSessionFactory" />  
    </bean>  
  
    <!-- 配置事务管理器 -->  
    <bean id="transactionManager"  
        class="org.springframework.jdbc.datasource.DataSourceTransactionManager">  
        <property name="dataSource" ref="dataSource" />  
    </bean>  
  
    <!-- 注解方式配置事物 -->  
    <tx:annotation-driven transaction-manager="transactionManager" />  
      
    <aop:aspectj-autoproxy proxy-target-class="true" />  
  
    <!-- 拦截器方式配置事物 -->  
    <!-- <tx:advice id="transactionAdvice" transaction-manager="transactionManager">  
        <tx:attributes>  
            <tx:method name="insert*" propagation="REQUIRED" />  
            <tx:method name="update*" propagation="REQUIRED" />  
            <tx:method name="delete*" propagation="REQUIRED" />  
  
            <tx:method name="get*" propagation="SUPPORTS" read-only="true" />  
            <tx:method name="find*" propagation="SUPPORTS" read-only="true" />  
            <tx:method name="select*" propagation="SUPPORTS" read-only="true" />  
  
        </tx:attributes>  
    </tx:advice>  
    <aop:config>  
        <aop:pointcut id="transactionPointcut"  
            expression="execution(* com.test.service.*.*(..))" />  
        <aop:advisor pointcut-ref="transactionPointcut"  
            advice-ref="transactionAdvice" />  
    </aop:config> -->  
  
</beans>


<?xml version="1.0" encoding="UTF-8"?>  
<beans xmlns="https://www.springframework.org/schema/beans"  
        xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance"   
        xmlns:context="https://www.springframework.org/schema/context"  
        xmlns:task="https://www.springframework.org/schema/task"   
    xsi:schemaLocation="https://www.springframework.org/schema/beans  
            https://www.springframework.org/schema/beans/spring-beans-4.1.xsd  
            https://www.springframework.org/schema/context  
            https://www.springframework.org/schema/context/spring-context-4.1.xsd  
            https://www.springframework.org/schema/task https://www.springframework.org/schema/task/spring-task-3.0.xsd">  
  
  
    <!-- <task:scheduled-tasks>     
        <task:scheduled ref="sendXMLTimerTask" method="run" cron="0 0/30 * * * ?"/>     
    </task:scheduled-tasks>  -->  
      
<!--   
cronExpression的配置说明,具体使用以及参数请百度google  
字段   允许值   允许的特殊字符  
秒    0-59    , - * /  
分    0-59    , - * /  
小时    0-23    , - * /  
日期    1-31    , - * ? / L W C  
月份    1-12 或者 JAN-DEC    , - * /  
星期    1-7 或者 SUN-SAT    , - * ? / L C #  
年(可选)    留空, 1970-2099    , - * /   
- 区间    
* 通配符    
? 你不想设置那个字段  
下面只例出几个式子  
   
CRON表达式    含义   
"0 0 12 * * ?"    每天中午十二点触发   
"0 15 10 ? * *"    每天早上10:15触发   
"0 15 10 * * ?"    每天早上10:15触发   
"0 15 10 * * ? *"    每天早上10:15触发   
"0 15 10 * * ? 2005"    2005年的每天早上10:15触发   
"0 * 14 * * ?"    每天从下午2点开始到2点59分每分钟一次触发   
"0 0/5 14 * * ?"    每天从下午2点开始到2:55分结束每5分钟一次触发   
"0 0/5 14,18 * * ?"    每天的下午2点至2:55和6点至6点55分两个时间段内每5分钟一次触发   
"0 0-5 14 * * ?"    每天14:00至14:05每分钟一次触发   
"0 10,44 14 ? 3 WED"    三月的每周三的14:10和14:44触发   
"0 15 10 ? * MON-FRI"    每个周一、周二、周三、周四、周五的10:15触发    
-->  
      
</beans>



<?xml version="1.0" encoding="UTF-8"?>  
<web-app xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance"  
    xmlns="https://java.sun.com/xml/ns/javaee" xmlns:web="https://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"  
    xsi:schemaLocation="https://java.sun.com/xml/ns/javaee https://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"  
    id="WebApp_ID" version="2.5">  
  
    <display-name>test</display-name>  
  
    <context-param>  
        <param-name>contextConfigLocation</param-name>  
        <param-value>classpath:spring.xml,classpath:spring-quartz.xml,classpath:spring-mybaties.xml</param-value>  
    </context-param>  
  
    <filter>  
        <filter-name>encodingFilter</filter-name>  
        <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>  
        <init-param>  
            <param-name>encoding</param-name>  
            <param-value>utf-8</param-value>  
        </init-param>  
        <init-param>  
            <param-name>forceEncoding</param-name>  
            <param-value>true</param-value>  
        </init-param>  
    </filter>  
    <filter-mapping>  
        <filter-name>encodingFilter</filter-name>  
        <url-pattern>/*</url-pattern>  
    </filter-mapping>  
  
    <listener>  
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>  
    </listener>  
  
    <!-- 防止spring内存溢出监听器 -->  
    <listener>  
        <listener-class>org.springframework.web.util.IntrospectorCleanupListener</listener-class>  
    </listener>  
  
    <servlet>  
        <servlet-name>test</servlet-name>  
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>  
        <init-param>  
            <param-name>contextConfigLocation</param-name>  
            <param-value>  
                classpath:spring-mvc.xml  
            </param-value>  
        </init-param>  
        <load-on-startup>1</load-on-startup>  
    </servlet>  
    <servlet-mapping>  
        <servlet-name>test</servlet-name>  
        <url-pattern>/</url-pattern>  
    </servlet-mapping>  
  
    <!-- 配置session超时时间,单位分钟 -->  
    <session-config>  
        <session-timeout>30</session-timeout>  
    </session-config>  
  
    <welcome-file-list>  
        <welcome-file>index.jsp</welcome-file>  
    </welcome-file-list>  
</web-app>


<project xmlns="https://maven.apache.org/POM/4.0.0" xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance"  
    xsi:schemaLocation="https://maven.apache.org/POM/4.0.0 https://maven.apache.org/maven-v4_0_0.xsd">  
    <modelVersion>4.0.0</modelVersion>  
    <groupId>com.test</groupId>  
    <artifactId>test</artifactId>  
    <packaging>war</packaging>  
    <version>0.0.1-SNAPSHOT</version>  
  
    <properties>  
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>  
        <spring.version>4.1.4.RELEASE</spring.version>  
        <jackson.version>2.5.0</jackson.version>  
    </properties>  
      
    <dependencies>  
        <dependency>  
            <groupId>junit</groupId>  
            <artifactId>junit</artifactId>  
            <version>4.12</version>  
            <scope>test</scope>  
        </dependency>  
  
        <!-- spring -->  
        <dependency>  
            <groupId>org.springframework</groupId>  
            <artifactId>spring-core</artifactId>  
            <version>${spring.version}</version>  
        </dependency>  
  
        <dependency>  
            <groupId>org.springframework</groupId>  
            <artifactId>spring-beans</artifactId>  
            <version>${spring.version}</version>  
        </dependency>  
  
        <dependency>  
            <groupId>org.springframework</groupId>  
            <artifactId>spring-context</artifactId>  
            <version>${spring.version}</version>  
        </dependency>  
  
        <dependency>  
            <groupId>org.springframework</groupId>  
            <artifactId>spring-tx</artifactId>  
            <version>${spring.version}</version>  
        </dependency>  
  
        <dependency>  
            <groupId>org.springframework</groupId>  
            <artifactId>spring-web</artifactId>  
            <version>${spring.version}</version>  
        </dependency>  
  
        <dependency>  
            <groupId>org.springframework</groupId>  
            <artifactId>spring-webmvc</artifactId>  
            <version>${spring.version}</version>  
        </dependency>  
  
        <dependency>  
            <groupId>org.springframework</groupId>  
            <artifactId>spring-jdbc</artifactId>  
            <version>${spring.version}</version>  
        </dependency>  
  
        <dependency>  
            <groupId>org.springframework</groupId>  
            <artifactId>spring-test</artifactId>  
            <version>${spring.version}</version>  
            <scope>test</scope>  
        </dependency>  
  
        <!-- mybatis 包 -->  
        <dependency>  
            <groupId>org.mybatis</groupId>  
            <artifactId>mybatis</artifactId>  
            <version>3.2.8</version>  
        </dependency>  
  
        <!--mybatis spring 插件 -->  
        <dependency>  
            <groupId>org.mybatis</groupId>  
            <artifactId>mybatis-spring</artifactId>  
            <version>1.2.2</version>  
        </dependency>  
  
        <!-- mysql连接 -->  
        <!-- <dependency>  
            <groupId>mysql</groupId>  
            <artifactId>mysql-connector-java</artifactId>  
            <version>5.1.34</version>  
        </dependency> -->  
  
        <!-- 数据源 -->  
        <!-- <dependency>  
            <groupId>com.alibaba</groupId>  
            <artifactId>druid</artifactId>  
            <version>1.0.12</version>  
        </dependency> -->  
        <!-- 数据库连接池 -->  
         <dependency>  
            <groupId>com.mchange</groupId>  
            <artifactId>c3p0</artifactId>  
            <version>0.9.5-pre8</version>  
        </dependency>  
  
        <!-- 生成class文件 -->  
        <dependency>  
            <groupId>org.aspectj</groupId>  
            <artifactId>aspectjweaver</artifactId>  
            <version>1.8.4</version>  
        </dependency>  
  
        <!-- log4j -->  
        <dependency>  
            <groupId>org.slf4j</groupId>  
            <artifactId>slf4j-api</artifactId>  
            <version>1.7.7</version>  
        </dependency>  
          
        <dependency>  
            <groupId>org.slf4j</groupId>  
            <artifactId>slf4j-log4j12</artifactId>  
            <version>1.7.7</version>  
        </dependency>  
          
        <dependency>  
            <groupId>log4j</groupId>  
            <artifactId>log4j</artifactId>  
            <version>1.2.17</version>  
        </dependency>  
  
        <!-- servlet -->  
        <dependency>  
            <groupId>javax.servlet</groupId>  
            <artifactId>servlet-api</artifactId>  
            <version>3.0-alpha-1</version>  
        </dependency>  
  
        <dependency>  
            <groupId>javax.servlet</groupId>  
            <artifactId>jstl</artifactId>  
            <version>1.2</version>  
        </dependency>  
  
        <!-- json -->  
        <dependency>  
            <groupId>org.codehaus.jackson</groupId>  
            <artifactId>jackson-mapper-asl</artifactId>  
            <version>1.9.13</version>  
        </dependency>  
  
        <dependency>  
            <groupId>com.alibaba</groupId>  
            <artifactId>fastjson</artifactId>  
            <version>1.2.3</version>  
        </dependency>  
  
        <dependency>  
            <groupId>com.fasterxml.jackson.core</groupId>  
            <artifactId>jackson-annotations</artifactId>  
            <version>${jackson.version}</version>  
        </dependency>  
  
        <dependency>  
            <groupId>com.fasterxml.jackson.core</groupId>  
            <artifactId>jackson-core</artifactId>  
            <version>${jackson.version}</version>  
        </dependency>  
  
        <dependency>  
            <groupId>com.fasterxml.jackson.core</groupId>  
            <artifactId>jackson-databind</artifactId>  
            <version>${jackson.version}</version>  
        </dependency>  
        <!-- 文件上传 -->  
        <dependency>  
            <groupId>commons-io</groupId>  
            <artifactId>commons-io</artifactId>  
            <version>2.4</version>  
        </dependency>  
  
        <dependency>  
            <groupId>commons-fileupload</groupId>  
            <artifactId>commons-fileupload</artifactId>  
            <version>1.2.2</version>  
        </dependency>  
          
        <!-- base64 -->  
        <dependency>  
            <groupId>commons-codec</groupId>  
            <artifactId>commons-codec</artifactId>  
            <version>1.10</version>  
        </dependency>  
          
        <!-- dom4j -->  
        <dependency>  
            <groupId>dom4j</groupId>  
            <artifactId>dom4j</artifactId>  
            <version>1.6.1</version>  
        </dependency>  
          
        <!-- XML  bean互转 -->  
        <dependency>  
            <groupId>com.thoughtworks.xstream</groupId>  
            <artifactId>xstream</artifactId>  
            <version>1.4.8</version>  
        </dependency>  
          
        <!-- oracle driver -->  
        <dependency>  
            <groupId>com.oracle</groupId>  
            <artifactId>ojdbc6</artifactId>  
            <version>11.2.0</version>  
        </dependency>  
          
        <!-- 定時任務 -->  
        <dependency>  
            <groupId>org.quartz-scheduler</groupId>  
            <artifactId>quartz</artifactId>  
            <version>2.2.1</version>  
        </dependency>  
          
        <dependency>  
            <groupId>org.springframework</groupId>  
            <artifactId>spring-context-support</artifactId>  
            <version>${spring.version}</version>  
        </dependency>  
          
        <dependency>  
            <groupId>commons-collections</groupId>  
            <artifactId>commons-collections</artifactId>  
            <version>3.2.1</version>  
        </dependency>  
          
    </dependencies>  
      
      
    <!-- 指定需要打包的文件 -->  
    <build>  
        <finalName>test</finalName>  
        <resources>  
            <resource>  
                <directory>src/main/java</directory>  
                <includes>  
                    <include>**/*.xml</include>  
                </includes>  
                <filtering>false</filtering>  
            </resource>  
            <resource>  
                <directory>src/main/resources</directory>  
                <includes>  
                    <include>**/*.xml</include>  
                    <include>**/*.properties</include>  
                </includes>  
                <filtering>false</filtering>  
            </resource>  
        </resources>  
    </build>  
  
</project>
点击复制链接 与好友分享!回本站首页
上一篇:Docker开发之把环境作为程序的一部分
下一篇:Cobertura 统计多模块maven项目测试覆盖率
相关文章
图文推荐
点击排行

关于我们 | 联系我们 | 广告服务 | 投资合作 | 版权申明 | 在线帮助 | 网站地图 | 作品发布 | Vip技术培训 | 举报中心

版权所有: 红黑联盟--致力于做实用的IT技术学习网站