Day72 SSM框架搭建(没有mybatisConfig.xml)

需要的jar包-MySQL

aopalliance.jar
asm-3.3.1.jar
aspectjweaver.jar
cglib-2.2.2.jar
commons-fileupload-1.3.1.jar
commons-io-2.2.jar
commons-logging-1.1.1.jar
commons-logging-1.1.3.jar
jackson-annotations-2.4.0.jar
jackson-core-2.4.1.jar
jackson-databind-2.4.1.jar
javassist-3.17.1-GA.jar
jstl-1.2.jar
kaptcha-2.3.jar
log4j-1.2.17.jar
log4j-api-2.0-rc1.jar
log4j-core-2.0-rc1.jar
mybatis-3.2.7.jar
mybatis-spring-1.2.3.jar
mysql-connector-java-5.1.30.jar
slf4j-api-1.7.5.jar
slf4j-log4j12-1.7.5.jar
spring-aop-4.1.6.RELEASE.jar
spring-aspects-4.1.6.RELEASE.jar
spring-beans-4.1.6.RELEASE.jar
spring-context-4.1.6.RELEASE.jar
spring-core-4.1.6.RELEASE.jar
spring-expression-4.1.6.RELEASE.jar
spring-jdbc-4.1.6.RELEASE.jar
spring-tx-4.1.6.RELEASE.jar
spring-web-4.1.6.RELEASE.jar
spring-webmvc-4.1.6.RELEASE.jar
standard-1.1.2.jar

applicationContext.xml


<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:context="http://www.springframework.org/schema/context"
      xmlns:tx="http://www.springframework.org/schema/tx"
    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.xsd
        http://www.springframework.org/schema/tx
        http://www.springframework.org/schema/tx/spring-tx.xsd
        http://www.springframework.org/schema/context
        http://www.springframework.org/schema/context/spring-context.xsd
        "
        default-autowire="byName"
        >

        
        <context:component-scan base-package="com.bjsxt.serviceImpl,com.bjsxt.pojo">context:component-scan>
        
        <aop:aspectj-autoproxy proxy-target-class="true" >aop:aspectj-autoproxy>
        
        <context:property-placeholder location="classpath:db.properties"/>
        
        <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
        <property name="driverClassName" value="${jdbc.driver}">property>
        <property name="url" value="${jdbc.url}">property>
        <property name="username" value="${jdbc.username}">property>
        <property name="password" value="${jdbc.password}">property>
        bean>
        
        <bean id="factory" class="org.mybatis.spring.SqlSessionFactoryBean">
        bean>
        
       <bean id="mapper" class="org.mybatis.spring.mapper.MapperScannerConfigurer">
       <property name="basePackage" value="com.bjsxt.mapper">property>
       <property name="sqlSessionFactoryBeanName" value="factory">property>
       bean>
       
         
         <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">bean>
         
         <tx:advice id="advice" transaction-manager="transactionManager">
         <tx:attributes>
         <tx:method name="ins*"/>
         <tx:method name="del*"/>
         <tx:method name="up*"/>
         <tx:method name="sel*" read-only="true"/>
         tx:attributes>
         tx:advice>
         
         <aop:config>
         <aop:pointcut expression="execution(* com.bjsxt.serviceImpl.*.*(..))" id="my"/>
         <aop:advisor advice-ref="advice" pointcut-ref="my"/>
         aop:config>
         
            
            
            
         
        beans>

db.properties

jdbc.driver=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://localhost:3306/mybatis
jdbc.username=root
jdbc.password=root

log4j.properties


log4j.rootCategory=info,LOGFILE



log4j.logger.com.bjsxt.mapper=debug, CONSOLE
log4j.logger.com.bjsxt.advice=debug, CONSOLE
log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
log4j.appender.CONSOLE.layout.ConversionPattern=- %c-%d-%m%n


log4j.appender.LOGFILE=org.apache.log4j.FileAppender
log4j.appender.LOGFILE.File=C:/BiZhi/axis.log
log4j.appender.LOGFILE.Append=true
log4j.appender.LOGFILE.layout=org.apache.log4j.PatternLayout
log4j.appender.LOGFILE.layout.ConversionPattern=- %c-%d-%m%n

springmvc.xml


<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:mvc="http://www.springframework.org/schema/mvc"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:context="http://www.springframework.org/schema/context"
    xsi:schemaLocation="
        http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/mvc
        http://www.springframework.org/schema/mvc/spring-mvc.xsd
        http://www.springframework.org/schema/context
        http://www.springframework.org/schema/context/spring-context.xsd">
        
        <context:component-scan base-package="com.bjsxt.controller">context:component-scan>
        
        <mvc:annotation-driven>mvc:annotation-driven>
        
        <mvc:resources location="/js/" mapping="/js/**">mvc:resources>
        <mvc:resources location="/css/" mapping="/css/**">mvc:resources>
        <mvc:resources location="/images/" mapping="/images/**">mvc:resources>

        
        <bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <property name="prefix" value="/WEB-INF/email/">property>
        <property name="suffix" value=".jsp">property>
        bean>
        
        <mvc:interceptors>
                <bean id="my2" class="com.bjsxt.intercepter.MyInter2">bean>
                <mvc:interceptor>
                    <mvc:mapping path="/demo"/>
                    <bean id="my" class="com.bjsxt.intercepter.MyInter">bean>
                mvc:interceptor>
            mvc:interceptors>
        
        <bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
        <property name="defaultEncoding" value="utf-8">property>
        <property name="maxInMemorySize" value="150000">property>
        <property name="maxUploadSize" value="1024123123">property>
        bean>
        
        <bean id="exceptionResolver" class="org.springframework.web.servlet.handler.SimpleMappingExceptionResolver">
        <property name="exceptionMappings">
        <props>
        <prop key="org.springframework.web.multipart.MaxUploadSizeExceededException">sizeLimitprop>
        props>
        property>
        bean>
        beans>

web.xml


<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_3_0.xsd" id="WebApp_ID" version="3.0">
  
  
  <context-param>
  <param-name>contextConfigLocationparam-name>
  <param-value>classpath:applicationContext.xmlparam-value>
  context-param>
  
  <listener><listener-class>org.springframework.web.context.ContextLoaderListenerlistener-class>listener>
  
  <servlet>
    <servlet-name>servlet123servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServletservlet-class>

    <init-param>
    <param-name>contextConfigLocationparam-name>
    <param-value>classpath:springmvc.xmlparam-value>
    init-param>
    <load-on-startup>1load-on-startup>
  servlet>
  <servlet-mapping>
    <servlet-name>servlet123servlet-name>
    <url-pattern>/url-pattern>
  servlet-mapping>
  
  <filter>
  <filter-name>encodingfilter-name>
  <filter-class>org.springframework.web.filter.CharacterEncodingFilterfilter-class>
  <init-param>
  <param-name>encodingparam-name>
  <param-value>utf-8param-value>
  init-param>
  <init-param>
 <param-name>forceEncodingparam-name>
 <param-value>trueparam-value>
 init-param>
  filter>
  <filter-mapping>
  <filter-name>encodingfilter-name>
  <url-pattern>/*url-pattern>
  filter-mapping>
web-app>

你可能感兴趣的:(SSM)