本人微信公众号"aeolian"~

SSM的Maven项目搭建过程

POM文件

父项目管理jar包,pom

        <modelVersion>4.0.0modelVersion>
    <groupId>cn.e3mallgroupId>
    <artifactId>e3-parentartifactId>
    <version>0.0.1-SNAPSHOTversion>
    <packaging>pompackaging>
    
    <properties>
        <junit.version>4.12junit.version>
        <spring.version>4.2.4.RELEASEspring.version>
        <mybatis.version>3.2.8mybatis.version>
        <mybatis.spring.version>1.2.2mybatis.spring.version>
        <mybatis.paginator.version>1.2.15mybatis.paginator.version>
        <mysql.version>5.1.32mysql.version>
        <slf4j.version>1.6.4slf4j.version>
        <jackson.version>2.4.2jackson.version>
        <druid.version>1.0.9druid.version>
        <httpclient.version>4.3.5httpclient.version>
        <jstl.version>1.2jstl.version>
        <servlet-api.version>2.5servlet-api.version>
        <jsp-api.version>2.0jsp-api.version>
        <joda-time.version>2.5joda-time.version>
        <commons-lang3.version>3.3.2commons-lang3.version>
        <commons-io.version>1.3.2commons-io.version>
        <commons-net.version>3.3commons-net.version>
        <pagehelper.version>3.4.2-fixpagehelper.version>
        <jsqlparser.version>0.9.1jsqlparser.version>
        <commons-fileupload.version>1.3.1commons-fileupload.version>
        <jedis.version>2.7.2jedis.version>
        <solrj.version>4.10.3solrj.version>
        <dubbo.version>2.5.3dubbo.version>
        <zookeeper.version>3.4.7zookeeper.version>
        <zkclient.version>0.1zkclient.version>
        <activemq.version>5.11.2activemq.version>
        <freemarker.version>2.3.23freemarker.version>
        <quartz.version>2.2.2quartz.version>
    properties>
    <dependencyManagement>
        <dependencies>
            
            <dependency>
                <groupId>joda-timegroupId>
                <artifactId>joda-timeartifactId>
                <version>${joda-time.version}version>
            dependency>
            
            <dependency>
                <groupId>org.apache.commonsgroupId>
                <artifactId>commons-lang3artifactId>
                <version>${commons-lang3.version}version>
            dependency>
            <dependency>
                <groupId>org.apache.commonsgroupId>
                <artifactId>commons-ioartifactId>
                <version>${commons-io.version}version>
            dependency>
            <dependency>
                <groupId>commons-netgroupId>
                <artifactId>commons-netartifactId>
                <version>${commons-net.version}version>
            dependency>
            
            <dependency>
                <groupId>com.fasterxml.jackson.coregroupId>
                <artifactId>jackson-databindartifactId>
                <version>${jackson.version}version>
            dependency>
            
            <dependency>
                <groupId>org.apache.httpcomponentsgroupId>
                <artifactId>httpclientartifactId>
                <version>${httpclient.version}version>
            dependency>
            
            <dependency>
                <groupId>org.quartz-schedulergroupId>
                <artifactId>quartzartifactId>
                <version>${quartz.version}version>
            dependency>
            
            <dependency>
                <groupId>junitgroupId>
                <artifactId>junitartifactId>
                <version>${junit.version}version>
                <scope>testscope>
            dependency>
            
            <dependency>
                <groupId>org.slf4jgroupId>
                <artifactId>slf4j-log4j12artifactId>
                <version>${slf4j.version}version>
            dependency>
            
            <dependency>
                <groupId>org.mybatisgroupId>
                <artifactId>mybatisartifactId>
                <version>${mybatis.version}version>
            dependency>
            <dependency>
                <groupId>org.mybatisgroupId>
                <artifactId>mybatis-springartifactId>
                <version>${mybatis.spring.version}version>
            dependency>
            <dependency>
                <groupId>com.github.miemiedevgroupId>
                <artifactId>mybatis-paginatorartifactId>
                <version>${mybatis.paginator.version}version>
            dependency>
            <dependency>
                <groupId>com.github.pagehelpergroupId>
                <artifactId>pagehelperartifactId>
                <version>${pagehelper.version}version>
            dependency>
            
            <dependency>
                <groupId>mysqlgroupId>
                <artifactId>mysql-connector-javaartifactId>
                <version>${mysql.version}version>
            dependency>
            
            <dependency>
                <groupId>com.alibabagroupId>
                <artifactId>druidartifactId>
                <version>${druid.version}version>
            dependency>
            
            <dependency>
                <groupId>org.springframeworkgroupId>
                <artifactId>spring-contextartifactId>
                <version>${spring.version}version>
            dependency>
            <dependency>
                <groupId>org.springframeworkgroupId>
                <artifactId>spring-beansartifactId>
                <version>${spring.version}version>
            dependency>
            <dependency>
                <groupId>org.springframeworkgroupId>
                <artifactId>spring-webmvcartifactId>
                <version>${spring.version}version>
            dependency>
            <dependency>
                <groupId>org.springframeworkgroupId>
                <artifactId>spring-jdbcartifactId>
                <version>${spring.version}version>
            dependency>
            <dependency>
                <groupId>org.springframeworkgroupId>
                <artifactId>spring-aspectsartifactId>
                <version>${spring.version}version>
            dependency>
            <dependency>
                <groupId>org.springframeworkgroupId>
                <artifactId>spring-jmsartifactId>
                <version>${spring.version}version>
            dependency>
            <dependency>
                <groupId>org.springframeworkgroupId>
                <artifactId>spring-context-supportartifactId>
                <version>${spring.version}version>
            dependency>
            
            <dependency>
                <groupId>jstlgroupId>
                <artifactId>jstlartifactId>
                <version>${jstl.version}version>
            dependency>
            <dependency>
                <groupId>javax.servletgroupId>
                <artifactId>servlet-apiartifactId>
                <version>${servlet-api.version}version>
                <scope>providedscope>
            dependency>
            <dependency>
                <groupId>javax.servletgroupId>
                <artifactId>jsp-apiartifactId>
                <version>${jsp-api.version}version>
                <scope>providedscope>
            dependency>
            
            <dependency>
                <groupId>commons-fileuploadgroupId>
                <artifactId>commons-fileuploadartifactId>
                <version>${commons-fileupload.version}version>
            dependency>
            
            <dependency>
                <groupId>redis.clientsgroupId>
                <artifactId>jedisartifactId>
                <version>${jedis.version}version>
            dependency>
            
            <dependency>
                <groupId>org.apache.solrgroupId>
                <artifactId>solr-solrjartifactId>
                <version>${solrj.version}version>
            dependency>
            
            <dependency>
                <groupId>com.alibabagroupId>
                <artifactId>dubboartifactId>
                <version>${dubbo.version}version>

dependency> <dependency> <groupId>org.apache.zookeepergroupId> <artifactId>zookeeperartifactId> <version>${zookeeper.version}version> dependency> <dependency> <groupId>com.github.sgroschupfgroupId> <artifactId>zkclientartifactId> <version>${zkclient.version}version> dependency> <dependency> <groupId>org.apache.activemqgroupId> <artifactId>activemq-allartifactId> <version>${activemq.version}version> dependency> <dependency> <groupId>org.freemarkergroupId> <artifactId>freemarkerartifactId> <version>${freemarker.version}version> dependency> dependencies> dependencyManagement> <build> <finalName>${project.artifactId}finalName> <plugins> <plugin> <groupId>org.apache.maven.pluginsgroupId> <artifactId>maven-resources-pluginartifactId> <version>2.7version> <configuration> <encoding>UTF-8encoding> configuration> plugin> <plugin> <groupId>org.apache.maven.pluginsgroupId> <artifactId>maven-compiler-pluginartifactId> <version>3.2version> <configuration> <source>1.7source> <target>1.7target> <encoding>UTF-8encoding> configuration> plugin> plugins> <pluginManagement> <plugins> <plugin> <groupId>org.apache.tomcat.mavengroupId> <artifactId>tomcat7-maven-pluginartifactId> <version>2.2version> plugin> plugins> pluginManagement> build>

子项目,工具项目,jar

<modelVersion>4.0.0modelVersion>
    <parent>
        <groupId>cn.e3mallgroupId>
        <artifactId>e3-parentartifactId>
        <version>0.0.1-SNAPSHOTversion>
    parent>
    <groupId>cn.e3mallgroupId>
    <artifactId>e3-commonartifactId>
    <version>0.0.1-SNAPSHOTversion>
    
    <dependencies>
        
        <dependency>
            <groupId>joda-timegroupId>
            <artifactId>joda-timeartifactId>
        dependency>
        
        <dependency>
            <groupId>org.apache.commonsgroupId>
            <artifactId>commons-lang3artifactId>
        dependency>
        <dependency>
            <groupId>org.apache.commonsgroupId>
            <artifactId>commons-ioartifactId>
        dependency>
        <dependency>
            <groupId>commons-netgroupId>
            <artifactId>commons-netartifactId>
        dependency>
        
        <dependency>
            <groupId>com.fasterxml.jackson.coregroupId>
            <artifactId>jackson-databindartifactId>
        dependency>
        
        <dependency>
            <groupId>org.apache.httpcomponentsgroupId>
            <artifactId>httpclientartifactId>
        dependency>
        
        <dependency>
            <groupId>org.quartz-schedulergroupId>
            <artifactId>quartzartifactId>
        dependency>
        
        <dependency>
            <groupId>junitgroupId>
            <artifactId>junitartifactId>
            <scope>testscope>
        dependency>
        
        <dependency>
            <groupId>org.slf4jgroupId>
            <artifactId>slf4j-log4j12artifactId>
        dependency>
    dependencies>

子项目,服务项目,聚合项目,pom

    <modelVersion>4.0.0modelVersion>
    <parent>
        <groupId>cn.e3mallgroupId>
        <artifactId>e3-parentartifactId>
        <version>0.0.1-SNAPSHOTversion>
    parent>
    <groupId>cn.e3mallgroupId>
    <artifactId>e3-managerartifactId>
    <version>0.0.1-SNAPSHOTversion>
    <packaging>pompackaging>

    <dependencies>
        
        <dependency>
            <groupId>cn.e3mallgroupId>
            <artifactId>e3-commonartifactId>
            <version>0.0.1-SNAPSHOTversion>
        dependency>
    dependencies>
    
    <modules>
        <module>e3-manager-pojomodule>
        <module>e3-manager-daomodule>
        <module>e3-manager-interfacemodule>
        <module>e3-manager-servicemodule>
        <module>e3-manager-webmodule>
    modules>
    
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.tomcat.mavengroupId>
                <artifactId>tomcat7-maven-pluginartifactId>
                <version>2.2version>
                <configuration>
                    <path>/path>
                    <port>8080port>
                configuration>
            plugin>
        plugins>
    build>

聚合项目子工程

pojo

  <modelVersion>4.0.0modelVersion>
  <parent>
    <groupId>cn.e3mallgroupId>
    <artifactId>e3-managerartifactId>
    <version>0.0.1-SNAPSHOTversion>
  parent>
  <artifactId>e3-manager-pojoartifactId>

dao

    <modelVersion>4.0.0modelVersion>
    <parent>
        <groupId>cn.e3mallgroupId>
        <artifactId>e3-managerartifactId>
        <version>0.0.1-SNAPSHOTversion>
    parent>
    
    <artifactId>e3-manager-daoartifactId>
    
    <dependencies>
        <dependency>
            <groupId>cn.e3mallgroupId>
            <artifactId>e3-manager-pojoartifactId>
            <version>0.0.1-SNAPSHOTversion>
        dependency>
        
            <dependency>
                <groupId>org.mybatisgroupId>
                <artifactId>mybatisartifactId>
            dependency>
            <dependency>
                <groupId>org.mybatisgroupId>
                <artifactId>mybatis-springartifactId>
            dependency>
            <dependency>
                <groupId>com.github.miemiedevgroupId>
                <artifactId>mybatis-paginatorartifactId>
            dependency>
            <dependency>
                <groupId>com.github.pagehelpergroupId>
                <artifactId>pagehelperartifactId>
            dependency>
            
            <dependency>
                <groupId>mysqlgroupId>
                <artifactId>mysql-connector-javaartifactId>
            dependency>
            
            <dependency>
                <groupId>com.alibabagroupId>
                <artifactId>druidartifactId>
            dependency>
    dependencies>
    
    <build>
        <resources>
            <resource>
                <directory>src/main/javadirectory>
                <includes>
                    <include>**/*.propertiesinclude>
                    <include>**/*.xmlinclude>
                includes>
                <filtering>falsefiltering>
            resource>
        resources>
    build>

interface

    <modelVersion>4.0.0modelVersion>
    <parent>
        <groupId>cn.e3mallgroupId>
        <artifactId>e3-managerartifactId>
        <version>0.0.1-SNAPSHOTversion>
    parent>
    <artifactId>e3-manager-interfaceartifactId>
    <dependencies>
        <dependency>
            <groupId>cn.e3mallgroupId>
            <artifactId>e3-manager-pojoartifactId>
            <version>0.0.1-SNAPSHOTversion>
        dependency>
    dependencies>

service

    <modelVersion>4.0.0modelVersion>
    <parent>
        <groupId>cn.e3mallgroupId>
        <artifactId>e3-managerartifactId>
        <version>0.0.1-SNAPSHOTversion>
    parent>
    <artifactId>e3-manager-serviceartifactId>
    <dependencies>
        <dependency>
            <groupId>cn.e3mallgroupId>
            <artifactId>e3-manager-daoartifactId>
            <version>0.0.1-SNAPSHOTversion>
        dependency>
        <dependency>
            <groupId>cn.e3mallgroupId>
            <artifactId>e3-manager-interfaceartifactId>
            <version>0.0.1-SNAPSHOTversion>
        dependency>
        
        <dependency>
            <groupId>org.springframeworkgroupId>
            <artifactId>spring-contextartifactId>
        dependency>
        <dependency>
            <groupId>org.springframeworkgroupId>
            <artifactId>spring-beansartifactId>
        dependency>
        <dependency>
            <groupId>org.springframeworkgroupId>
            <artifactId>spring-webmvcartifactId>
        dependency>
        <dependency>
            <groupId>org.springframeworkgroupId>
            <artifactId>spring-jdbcartifactId>
        dependency>
        <dependency>
            <groupId>org.springframeworkgroupId>
            <artifactId>spring-aspectsartifactId>
        dependency>
        <dependency>
            <groupId>org.springframeworkgroupId>
            <artifactId>spring-jmsartifactId>
        dependency>
        <dependency>
            <groupId>org.springframeworkgroupId>
            <artifactId>spring-context-supportartifactId>
        dependency>
    dependencies>

web

    <modelVersion>4.0.0modelVersion>
    <parent>
        <groupId>cn.e3mallgroupId>
        <artifactId>e3-managerartifactId>
        <version>0.0.1-SNAPSHOTversion>
    parent>
    <artifactId>e3-manager-webartifactId>
    <packaging>warpackaging>

    <dependencies>
        <dependency>
            <groupId>cn.e3mallgroupId>
            <artifactId>e3-manager-serviceartifactId>
            <version>0.0.1-SNAPSHOTversion>
        dependency>
        
        <dependency>
            <groupId>jstlgroupId>
            <artifactId>jstlartifactId>
            <version>${jstl.version}version>
        dependency>
        <dependency>
            <groupId>javax.servletgroupId>
            <artifactId>servlet-apiartifactId>
            <version>${servlet-api.version}version>
            <scope>providedscope>
        dependency>
        <dependency>
            <groupId>javax.servletgroupId>
            <artifactId>jsp-apiartifactId>
            <version>${jsp-api.version}version>
            <scope>providedscope>
        dependency>
    dependencies>

配置文件

在web子项目src/main/resource中新建conf,mybatis,spring文件夹

conf/db.properties文件

jdbc.driver=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://localhost:3306/e3mall-32?characterEncoding=utf-8
jdbc.username=qy
jdbc.password=199526

mybatis/SqlMapConfig.xml

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>
configuration>

spring/applicationContext-dao.xml

xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:context="http://www.springframework.org/schema/context" xmlns:p="http://www.springframework.org/schema/p"
    xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.2.xsd
    http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.2.xsd
    http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.2.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.2.xsd
    http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.2.xsd">

    
    
    <context:property-placeholder location="classpath:conf/db.properties" />
    
    <bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource"
        destroy-method="close">
        <property name="url" value="${jdbc.url}" />
        <property name="username" value="${jdbc.username}" />
        <property name="password" value="${jdbc.password}" />
        <property name="driverClassName" value="${jdbc.driver}" />
        <property name="maxActive" value="10" />
        <property name="minIdle" value="5" />
    bean>
    
    <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
        
        <property name="dataSource" ref="dataSource" />
        
        <property name="configLocation" value="classpath:mybatis/SqlMapConfig.xml" />
    bean>
    <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
        <property name="basePackage" value="cn.e3mall.mapper" />
    bean>
beans>

spring/applicationContext-service.xml

xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:context="http://www.springframework.org/schema/context" xmlns:p="http://www.springframework.org/schema/p"
    xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.2.xsd
    http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.2.xsd
    http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.2.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.2.xsd
    http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.2.xsd">
    
    <context:component-scan base-package="cn.e3mall.service"/>
beans>

spring/applicationContext-trans.xml

<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:context="http://www.springframework.org/schema/context" xmlns:p="http://www.springframework.org/schema/p"
    xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.2.xsd
    http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.2.xsd
    http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.2.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.2.xsd
    http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.2.xsd">
    
    <bean id="transactionManager"
        class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
        
        <property name="dataSource" ref="dataSource" />
    bean>
    
    <tx:advice id="txAdvice" transaction-manager="transactionManager">
        <tx:attributes>
            
            <tx:method name="save*" propagation="REQUIRED" />
            <tx:method name="insert*" propagation="REQUIRED" />
            <tx:method name="add*" propagation="REQUIRED" />
            <tx:method name="create*" propagation="REQUIRED" />
            <tx:method name="delete*" propagation="REQUIRED" />
            <tx:method name="update*" propagation="REQUIRED" />
            <tx:method name="find*" propagation="SUPPORTS" read-only="true" />
            <tx:method name="select*" propagation="SUPPORTS" read-only="true" />
            <tx:method name="get*" propagation="SUPPORTS" read-only="true" />
        tx:attributes>
    tx:advice>
    
    <aop:config>
    
        <aop:advisor advice-ref="txAdvice"
            pointcut="execution(* cn.e3mall.service..*.*(..))" />
    aop:config>
beans>

spring/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:p="http://www.springframework.org/schema/p"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:mvc="http://www.springframework.org/schema/mvc"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.2.xsd
        http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.2.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.2.xsd">
    
    <context:component-scan base-package="cn.e3mall.controller" />
    
    <mvc:annotation-driven />
    
    <bean
        class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <property name="prefix" value="/WEB-INF/jsp/" />
        <property name="suffix" value=".jsp" />
    bean>
beans>

web.xml

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">
  <display-name>e3-manager-webdisplay-name>
  <welcome-file-list>
    <welcome-file>index.htmlwelcome-file>
    <welcome-file>index.htmwelcome-file>
    <welcome-file>index.jspwelcome-file>
    <welcome-file>default.htmlwelcome-file>
    <welcome-file>default.htmwelcome-file>
    <welcome-file>default.jspwelcome-file>
  welcome-file-list>
  
      
    <context-param>    
        <param-name>log4jConfigLocationparam-name>    
        <param-value>/WEB-INF/log4j.propertiesparam-value>    
    context-param>    
        
    <context-param>    
        <param-name>log4jRefreshIntervalparam-name>    
        <param-value>60000param-value>    
    context-param>    
    <listener>    
        <listener-class>    
            org.springframework.web.util.Log4jConfigListener    
        listener-class>    
    listener>    
      
  
  
    <context-param>
        <param-name>contextConfigLocationparam-name>
        <param-value>classpath:spring/applicationContext*.xmlparam-value>
    context-param>
    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListenerlistener-class>
    listener>
    
    
    <filter>
        <filter-name>CharacterEncodingFilterfilter-name>
        <filter-class>org.springframework.web.filter.CharacterEncodingFilterfilter-class>
        <init-param>
            <param-name>encodingparam-name>
            <param-value>utf-8param-value>
        init-param>
    filter>
    <filter-mapping>
        <filter-name>CharacterEncodingFilterfilter-name>
        <url-pattern>/*url-pattern>
    filter-mapping>

    
    <servlet>
        <servlet-name>e3-managerservlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServletservlet-class>
        
        <init-param>
            <param-name>contextConfigLocationparam-name>
            <param-value>classpath:spring/springmvc.xmlparam-value>
        init-param>
        <load-on-startup>1load-on-startup>
    servlet>
    <servlet-mapping>
        <servlet-name>e3-managerservlet-name>
        <url-pattern>/url-pattern>
    servlet-mapping>
web-app>

WEB-INF/log4j.properties

log4j.rootLogger=DEBUG,A1
log4j.appender.A1=org.apache.log4j.ConsoleAppender
log4j.appender.A1.layout=org.apache.log4j.PatternLayout
log4j.appender.A1.layout.ConversionPattern=%-d{yyyy-MM-dd HH:mm:ss,SSS} [%t] [%c]-[%p] %m%n

controller测试

在cn.e3mall.controller中新建

@Controller
@RequestMapping("/loginController")
public class LoginController {
    @RequestMapping("/login")
    @ResponseBody
    public Users login(){
        Users users = new Users();
        users.setName("autumn");
        users.setAge(22);
        users.setSex(0);
        users.setGroupCode("45678979");
        return users;
    }
}

浏览器页面

《SSM的Maven项目搭建过程》

文件链接

点赞

Leave a Reply

Your email address will not be published. Required fields are marked *