zoukankan      html  css  js  c++  java
  • SSM项目的配置文件

    记不住ssm配置文件的我默默的备份了一下,方便以后快速搭建框架:

    1.pom.xml

    <?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">
      <modelVersion>4.0.0</modelVersion>
    
      <groupId>com.zhibo</groupId>
      <artifactId>Zhiboproject</artifactId>
      <version>1.0-SNAPSHOT</version>
      <packaging>war</packaging>
    
      <name>Zhiboproject Maven Webapp</name>
      <!-- FIXME change it to the project's website -->
      <url>http://www.example.com</url>
    
      <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.source>1.7</maven.compiler.source>
        <maven.compiler.target>1.7</maven.compiler.target>
        <spring.version>4.3.25.RELEASE</spring.version>
        <mybatis.version>3.4.6</mybatis.version>
        <mybatis-spring.version>1.3.2</mybatis-spring.version>
        <pagehelper.version>5.1.4</pagehelper.version>
        <mysql.version>5.1.47</mysql.version>
        <c3p0.version>0.9.5.2</c3p0.version>
        <lombok.version>1.18.8</lombok.version>
        <jsp-api.version>2.3.1</jsp-api.version>
        <servlet-api.version>3.1.0</servlet-api.version>
        <jstl.version>1.2</jstl.version>
        <standard.version>1.1.2</standard.version>
        <log4j.version>1.2.17</log4j.version>
        <hibernate-validator.version>6.0.7.Final</hibernate-validator.version>
        <fileupload.version>1.4</fileupload.version>
        <lang.version>2.1</lang.version>
        <jackson.version>2.9.8</jackson.version>
    
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.source>1.7</maven.compiler.source>
        <maven.compiler.target>1.7</maven.compiler.target>
      </properties>
    
        <dependencies>
          <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.12</version>
            <scope>test</scope>
          </dependency>
    
          <!--springmvc的相关依赖-->
          <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
            <version>${spring.version}</version>
          </dependency>
          <!--面向切面编程相关依赖-->
          <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-aspects</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>
          </dependency>
    
          <dependency>
            <groupId>org.hibernate.validator</groupId>
            <artifactId>hibernate-validator</artifactId>
            <version>${hibernate-validator.version}</version>
          </dependency>
    
    
          <dependency>
            <groupId>org.mybatis</groupId>
            <artifactId>mybatis</artifactId>
            <version>${mybatis.version}</version>
          </dependency>
          <dependency>
            <groupId>org.mybatis</groupId>
            <artifactId>mybatis-spring</artifactId>
            <version>${mybatis-spring.version}</version>
          </dependency>
    
          <dependency>
            <groupId>com.github.pagehelper</groupId>
            <artifactId>pagehelper</artifactId>
            <version>${pagehelper.version}</version>
          </dependency>
    
          <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>${mysql.version}</version>
          </dependency>
    
          <dependency>
            <groupId>com.mchange</groupId>
            <artifactId>c3p0</artifactId>
            <version>${c3p0.version}</version>
          </dependency>
    
    
          <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <version>${lombok.version}</version>
            <scope>provided</scope>
          </dependency>
    
          <dependency>
            <groupId>javax.servlet.jsp</groupId>
            <artifactId>javax.servlet.jsp-api</artifactId>
            <version>${jsp-api.version}</version>
            <scope>provided</scope>
          </dependency>
    
          <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
            <version>${servlet-api.version}</version>
            <scope>provided</scope>
          </dependency>
    
          <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>jstl</artifactId>
            <version>${jstl.version}</version>
          </dependency>
    
          <dependency>
            <groupId>taglibs</groupId>
            <artifactId>standard</artifactId>
            <version>${standard.version}</version>
          </dependency>
    
          <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>${log4j.version}</version>
          </dependency>
    
          <dependency>
            <groupId>commons-fileupload</groupId>
            <artifactId>commons-fileupload</artifactId>
            <version>${fileupload.version}</version>
          </dependency>
    
          <dependency>
            <groupId>commons-lang</groupId>
            <artifactId>commons-lang</artifactId>
            <version>${lang.version}</version>
          </dependency>
    
          <!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-databind -->
          <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
            <version>${jackson.version}</version>
          </dependency>
    
        </dependencies>
    
    
      <build>
        <resources>
      <!-- 放过java和resources里面的配置文件 -->
    <resource> <directory>src/main/java</directory> <includes> <include>**/*.xml</include> </includes> </resource> <resource> <directory>src/main/resources</directory> <includes> <include>**/*</include> </includes> </resource> </resources>
      <!--要使用插件,必须把插件从<pluginManagement></pluginManagement>标签里拿出来--> <pluginManagement> <plugins>
    <!--tomcat的插件 嵌入式的tomcat服务器 jar包 社区版的idea靠这个tomcat了^_^--> <plugin> <groupId>org.apache.tomcat.maven</groupId> <artifactId>tomcat7-maven-plugin</artifactId> <version>2.2</version> <configuration> <hostName>localhost</hostName> <!-- Default: localhost --> <port>8080</port> <!-- 启动端口 Default:8080 --> <path>/</path> <!-- 访问应用路径 Default: /${project.artifactId}--> <uriEncoding>UTF-8</uriEncoding> <!-- uri编码 Default: ISO-8859-1 --> </configuration> </plugin>   <!--下面的插件为mybatis代码生成器插件可忽略--> <plugin> <groupId>org.mybatis.generator</groupId> <artifactId>mybatis-generator-maven-plugin</artifactId> <version>1.3.2</version> <configuration> <!--配置文件的位置--> <configurationFile>src/main/resources/MybatisGenerator.xml</configurationFile> <verbose>true</verbose> <overwrite>true</overwrite> </configuration> <dependencies> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>5.1.47</version> </dependency> </dependencies> </plugin>
    </plugins> </pluginManagement> </build> </project>

    2.jdbc.properties

    mysql.driver=com.mysql.jdbc.Driver
    mysql.url=jdbc:mysql://192.168.187.51:3306/demo?useUnicode=true&amp;characterEncoding=UTF-8
    mysql.user=root
    mysql.password=123456

    3.log4j.properties

    #配置根节点
    log4j.rootLogger=INFO,Log4jConsole
    
    #自定义
    #log4j.logger 自定义的日志级别
    #org.apache.ibatis 包名 我自定义日志的目的是为了打印xxx包下的日志
    #INFO 什么都看不到
    #WARN 可以看到sql语句
    #DEBUG 所有的实现细节
    log4j.logger.org.apache.ibatis=INFO
    
    #控制台输出
    log4j.appender.Log4jConsole=org.apache.log4j.ConsoleAppender
    log4j.appender.Log4jConsole.Threshold=INFO
    log4j.appender.Log4jConsole.ImmediateFlush=true
    log4j.appender.Log4jConsole.Target=System.out
    #输出格式
    log4j.appender.Log4jConsole.layout=org.apache.log4j.PatternLayout
    log4j.appender.Log4jConsole.layout.ConversionPattern=[%p][%d{yyyy-MM-dd HH:mm:ss,SSS}] [%c:%M:%L] %m%n
    
    l [%t] [%c] [%p] [%L]- %m%n ,日志的布局方式,%开头的字符意义如下:.appender.myfile.layout.ConversionPattern=%d{yyyy-MM-og4jdd HH:mm:ss}

    4.springmvc.xml

    <?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:tx="http://www.springframework.org/schema/tx"
           xmlns:context="http://www.springframework.org/schema/context"
           xmlns:task="http://www.springframework.org/schema/task"
           xmlns:mvc="http://www.springframework.org/schema/mvc"
           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-4.1.xsd
            http://www.springframework.org/schema/tx
            http://www.springframework.org/schema/tx/spring-tx-4.1.xsd
            http://www.springframework.org/schema/context
            http://www.springframework.org/schema/context/spring-context-4.1.xsd
            http://www.springframework.org/schema/task
            http://www.springframework.org/schema/task/spring-task-4.1.xsd
            http://www.springframework.org/schema/mvc
            http://www.springframework.org/schema/mvc/spring-mvc-4.1.xsd">
    
    
          <!--引入外部属性文件-->
          <context:property-placeholder location="classpath*:*jdbc.properties"></context:property-placeholder>
    
          <!--配置扫描-->
          <context:component-scan base-package="com.blb"></context:component-scan>
    
    
          <!--MVC的注解支持-->
          <mvc:annotation-driven></mvc:annotation-driven>
    
          <!--放过静态资源-->
          <mvc:default-servlet-handler></mvc:default-servlet-handler>
    
          <!--视图解析器-->
          <!--<bean id="internalResourceViewResolver"  class="org.springframework.web.servlet.view.InternalResourceViewResolver">
              <property name="prefix" value="/WEB-INF/pages/"></property>
              <property name="suffix" value=".html"></property>
          </bean> -->
    
    
          <!--引入文件上传-->
          <bean id="multipartResolver"  class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
              <property name="maxUploadSize" value="10000000"></property>
              <property name="defaultEncoding" value="UTF-8"></property>
          </bean>
    
    
    
          <!--配置连接池-->
          <bean  id="datasource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
              <property name="driverClass" value="${mysql.driver}"></property>
              <property name="jdbcUrl" value="${mysql.url}"></property>
              <property name="user" value="${mysql.user}"></property>
              <property name="password" value="${mysql.password}"></property>
          </bean>
    
    
          <!--sqlsessionFactoryBean-->
           <bean id="sqlSessionFactoryBean" class="org.mybatis.spring.SqlSessionFactoryBean">
               <property name="dataSource" ref="datasource"></property>
               <property name="mapperLocations" value="classpath*:*com/blb/dao/*.xml"></property>
               <property name="plugins">
                   <bean class="com.github.pagehelper.PageInterceptor">
                       <property name="properties">
                           <props>
                               <prop key="helperDialect">mysql</prop>
                           </props>
                       </property>
                   </bean>
               </property>
           </bean>
    
          <!--把所有的mapper加入到ioc容器中-->
          <bean id="mapperScannerConfigurer" class="org.mybatis.spring.mapper.MapperScannerConfigurer">
              <property name="sqlSessionFactoryBeanName" value="sqlSessionFactoryBean"></property>
              <property name="basePackage" value="com.blb.dao"></property>
          </bean>
    
    
          <!--切面-->
          <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
              <property name="dataSource" ref="datasource"></property>
          </bean>
    
    
          <aop:aspectj-autoproxy></aop:aspectj-autoproxy>
    
          <!--注解式切面-->
          <tx:annotation-driven transaction-manager="transactionManager"></tx:annotation-driven>
    </beans>

    5.web.xml

    <?xml version="1.0" encoding="UTF-8"?>
    
    <web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
                          http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
             version="3.1">
      <display-name>Archetype Created Web Application</display-name>
    
      <!--告诉程序springmvc配置文件的位置,如果不写只能使用默认的springmvc配置文件名--> <servlet> <servlet-name>springmvc</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <init-param> <param-name>contextConfigLocation</param-name> <param-value>classpath*:*springmvc.xml</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>springmvc</servlet-name> <url-pattern>/</url-pattern> </servlet-mapping>
    <!--过滤器的相关配置--> <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> </filter> <filter-mapping> <filter-name>EncodingFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <filter> <filter-name>HiddenHttpMethodFilter</filter-name> <filter-class>org.springframework.web.filter.HiddenHttpMethodFilter</filter-class> </filter> <filter-mapping> <filter-name>HiddenHttpMethodFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> </web-app>
  • 相关阅读:
    查看端口有没有被占用
    微信公众号2()
    How to insert a segment of noise to music file
    puppet practice
    Docker Commands
    LempelZiv algorithm realization
    The algorithm of entropy realization
    Java network programmingguessing game
    Deploy Openstack with RDO and Change VNC console to Spice
    puppet overview
  • 原文地址:https://www.cnblogs.com/theyang/p/12802172.html
Copyright © 2011-2022 走看看