ssm三大结构整合ITeye - 乐橙lc8

ssm三大结构整合ITeye

2019-01-11 11:29:22 | 作者: 德运 | 标签: 装备,文件,整合 | 浏览: 1642

 ?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:aop="http://www.springframework.org/schema/aop" 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.0.xsd 
 http://www.springframework.org/schema/context 
 http://www.springframework.org/schema/context/spring-context-4.0.xsd 
 http://www.springframework.org/schema/mvc 
 http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd 
 http://www.springframework.org/schema/aop 
 http://www.springframework.org/schema/aop/spring-aop-4.0.xsd" 
 !-- 需求扫除操控层用到的注解,比方@Controller等 -- 
 context:component-scan base-package="com.huan.shiro"
 annotation-config="true" 
 context:include-filter type="annotation"
 expression="org.springframework.stereotype.Controller" / 
 context:exclude-filter type="annotation"
 expression="org.springframework.stereotype.Service" / 
 context:exclude-filter type="annotation"
 expression="org.springframework.stereotype.Repository" / 
 /context:component-scan 
 bean id="mappingJackson2HttpMessageConverter"
 property name="supportedMediaTypes" 
 list 
 value text/html;charset=UTF-8 /value 
 /list 
 /property 
 /bean 
 bean
 property name="messageConverters" 
 list 
 ref bean="mappingJackson2HttpMessageConverter" / 
 /list 
 /property 
 /bean 
 bean
 property name="prefix" value="/WEB-INF/jsp/" / 
 property name="suffix" value=".jsp" / 
 property name="viewClass"
 value="org.springframework.web.servlet.view.JstlView" / 
 /bean 
 bean id="multipartResolver"
 property name="defaultEncoding" value="utf-8" / 
 property name="maxUploadSize" value="102400" / 
 property name="maxInMemorySize" value="40960" / 
 /bean 
 mvc:annotation-driven / 
 !-- 处理静态资源 -- 
 mvc:default-servlet-handler / 
 /beans 

 2.web.xml装备文件装备( 需求留意spring的装备文件和spirngmvc的装备文件分隔加载 )

 

 

 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 
 context-param 
 param-name contextConfigLocation /param-name 
 param-value 
 classpath:spring/spring.xml
 classpath:spring/spring-mybatis.xml
 /param-value 
 /context-param 
 listener 
 listener-class org.springframework.web.context.ContextLoaderListener /listener-class 
 /listener 
 listener 
 listener-class org.springframework.web.util.IntrospectorCleanupListener /listener-class 
 /listener 
 servlet 
 servlet-name dispatcherServlet /servlet-name 
 servlet-class org.springframework.web.servlet.DispatcherServlet /servlet-class 
 !-- 没有指定途径,默许是找WEB-INF下的 dispatcherServlet-servlet.xml文件 -- 
 init-param 
 param-name contextConfigLocation /param-name 
 param-value classpath:spring/spring-mvc.xml /param-value 
 /init-param 
 load-on-startup 1 /load-on-startup 
 /servlet 
 servlet-mapping 
 servlet-name dispatcherServlet /servlet-name 
 url-pattern / /url-pattern 
 /servlet-mapping 
 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 
 async-supported true /async-supported 
 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 
 /web-app 

 3.spring整合mybatis( 需求留意运用mapper扫描时,扫描的包的方位,此处我需求在mapper接口在加一个自定义注解,否则形似有问题。 )

 ?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:aop="http://www.springframework.org/schema/aop" xmlns:mvc="http://www.springframework.org/schema/mvc"
 xmlns:tx="http://www.springframework.org/schema/tx"
 xsi:schemaLocation="http://www.springframework.org/schema/beans 
 http://www.springframework.org/schema/beans/spring-beans-4.0.xsd 
 http://www.springframework.org/schema/context 
 http://www.springframework.org/schema/context/spring-context-4.0.xsd 
 http://www.springframework.org/schema/aop 
 http://www.springframework.org/schema/aop/spring-aop-4.0.xsd 
 http://www.springframework.org/schema/mvc 
 http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd
 http://www.springframework.org/schema/tx
 http://www.springframework.org/schema/tx/spring-tx-4.0.xsd" 
 bean id="dataSource" destroy-method="close" init-method="init" 
 property name="driverClassName" value="${driver}" / 
 property name="url" value="${url}" / 
 property name="username" value="${username}" / 
 property name="password" value="${password}" / 
 property name="initialSize" value="${initialSize}" / 
 property name="maxActive" value="${maxActive}" / 
 property name="minIdle" value="${minIdle}" / 
 property name="maxWait" value="${maxWait}" / 
 property name="testWhileIdle" value="true" / 
 property name="testOnBorrow" value="true" / 
 property name="testOnReturn" value="false" / 
 property name="validationQuery" value="select 1 from dual" / 
 /bean 
 bean id="sqlSessionFactory" 
 property name="dataSource" ref="dataSource" / 
 property name="mapperLocations" value="classpath:sqlmaps/**/*.xml" /property 
 /bean 
 bean 
 property name="basePackage" value="com.huan.shiro" / 
 property name="annotationClass" value="com.huan.shiro.annotation.Mapper" / 
 property name="sqlSessionFactoryBeanName" value="sqlSessionFactory" / 
 /bean 
 bean id="transactionManager"
 property name="dataSource" ref="dataSource" / 
 /bean 
 tx:annotation-driven transaction-manager="txManager" / 
 /beans 

 4.spring的一个装备文件

 ?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:aop="http://www.springframework.org/schema/aop" xmlns:mvc="http://www.springframework.org/schema/mvc"
 xmlns:tx="http://www.springframework.org/schema/tx"
 xsi:schemaLocation="http://www.springframework.org/schema/beans 
 http://www.springframework.org/schema/beans/spring-beans-4.0.xsd 
 http://www.springframework.org/schema/context 
 http://www.springframework.org/schema/context/spring-context-4.0.xsd 
 http://www.springframework.org/schema/aop 
 http://www.springframework.org/schema/aop/spring-aop-4.0.xsd 
 http://www.springframework.org/schema/mvc 
 http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd
 http://www.springframework.org/schema/tx
 http://www.springframework.org/schema/tx/spring-tx-4.0.xsd" 
 !-- 主动扫描 -- 
 context:component-scan base-package="com.huan.shiro"
 annotation-config="true" 
 context:exclude-filter type="annotation"
 expression="org.springframework.stereotype.Controller" / 
 /context:component-scan 
 !-- 引进装备文件 -- 
 bean id="propertyConfigurer"
 property name="ignoreResourceNotFound" value="true" / 
 property name="locations" 
 list 
 value classpath:jdbc.properties /value 
 /list 
 /property 
 /bean 
 aop:aspectj-autoproxy / 
 /beans 

5.pom装备文件

 ?xml version="1.0"? 
 project
 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
 xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
 modelVersion 4.0.0 /modelVersion 
 parent 
 groupId com.huan.shiro /groupId 
 artifactId shiro-parent /artifactId 
 version 0.0.1-SNAPSHOT /version 
 /parent 
 artifactId shiro-spring /artifactId 
 packaging war /packaging 
 name shiro-spring Maven Webapp /name 
 url http://maven.apache.org /url 
 properties 
 springVersion 4.2.7.RELEASE /springVersion 
 slf4j.version 1.7.21 /slf4j.version 
 /properties 
 dependencies 
 dependency 
 groupId junit /groupId 
 artifactId junit /artifactId 
 /dependency 
 dependency 
 groupId org.springframework /groupId 
 artifactId spring-core /artifactId 
 version 4.2.7.RELEASE /version 
 /dependency 
 dependency 
 groupId org.springframework /groupId 
 artifactId spring-test /artifactId 
 version 4.2.7.RELEASE /version 
 /dependency 
 dependency 
 groupId org.springframework /groupId 
 artifactId spring-context /artifactId 
 version 4.2.7.RELEASE /version 
 /dependency 
 dependency 
 groupId org.springframework /groupId 
 artifactId spring-context-support /artifactId 
 version 4.2.7.RELEASE /version 
 /dependency 
 dependency 
 groupId org.springframework /groupId 
 artifactId spring-tx /artifactId 
 version 4.2.7.RELEASE /version 
 /dependency 
 dependency 
 groupId org.springframework /groupId 
 artifactId spring-jdbc /artifactId 
 version 4.2.7.RELEASE /version 
 /dependency 
 dependency 
 groupId org.springframework /groupId 
 artifactId spring-web /artifactId 
 version 4.2.7.RELEASE /version 
 /dependency 
 dependency 
 groupId org.springframework /groupId 
 artifactId spring-webmvc /artifactId 
 version 4.2.7.RELEASE /version 
 /dependency 
 dependency 
 groupId org.springframework /groupId 
 artifactId spring-expression /artifactId 
 version 4.2.7.RELEASE /version 
 /dependency 
 dependency 
 groupId org.springframework /groupId 
 artifactId spring-aop /artifactId 
 version 4.2.7.RELEASE /version 
 /dependency 
 dependency 
 groupId org.mybatis /groupId 
 artifactId mybatis /artifactId 
 version 3.3.0 /version 
 /dependency 
 dependency 
 groupId org.mybatis /groupId 
 artifactId mybatis-spring /artifactId 
 version 1.2.2 /version 
 /dependency 
 !-- AOP begin -- 
 dependency 
 groupId org.aspectj /groupId 
 artifactId aspectjrt /artifactId 
 version 1.7.4 /version 
 /dependency 
 dependency 
 groupId org.aspectj /groupId 
 artifactId aspectjweaver /artifactId 
 version 1.7.4 /version 
 /dependency 
 dependency 
 groupId cglib /groupId 
 artifactId cglib /artifactId 
 version 3.1 /version 
 /dependency 
 !-- AOP end -- 
 dependency 
 groupId org.apache.shiro /groupId 
 artifactId shiro-core /artifactId 
 /dependency 
 dependency 
 groupId org.apache.shiro /groupId 
 artifactId shiro-web /artifactId 
 /dependency 
 dependency 
 groupId org.apache.shiro /groupId 
 artifactId shiro-spring /artifactId 
 version ${shiro.version} /version 
 /dependency 
 dependency 
 groupId com.alibaba /groupId 
 artifactId druid /artifactId 
 version 1.0.19 /version 
 /dependency 
 dependency 
 groupId mysql /groupId 
 artifactId mysql-connector-java /artifactId 
 version 5.1.37 /version 
 /dependency 
 dependency 
 groupId taglibs /groupId 
 artifactId standard /artifactId 
 version 1.1.2 /version 
 type jar /type 
 /dependency 
 dependency 
 groupId javax.servlet /groupId 
 artifactId jstl /artifactId 
 version 1.2 /version 
 type jar /type 
 /dependency 
 dependency 
 groupId javax.servlet /groupId 
 artifactId javax.servlet-api /artifactId 
 scope provided /scope 
 /dependency 
 dependency 
 groupId javax.servlet.jsp /groupId 
 artifactId jsp-api /artifactId 
 version 2.2 /version 
 scope provided /scope 
 /dependency 
 dependency 
 groupId org.slf4j /groupId 
 artifactId slf4j-api /artifactId 
 /dependency 
 dependency 
 groupId org.slf4j /groupId 
 artifactId slf4j-log4j12 /artifactId 
 version ${slf4j.version} /version 
 /dependency 
 !-- common-logging 实践调用slf4j -- 
 dependency 
 groupId org.slf4j /groupId 
 artifactId jcl-over-slf4j /artifactId 
 /dependency 
 !-- java.util.logging 实践调用slf4j -- 
 dependency 
 groupId org.slf4j /groupId 
 artifactId jul-to-slf4j /artifactId 
 version ${slf4j.version} /version 
 /dependency 
 dependency 
 groupId com.fasterxml.jackson.core /groupId 
 artifactId jackson-databind /artifactId 
 version 2.7.4 /version 
 /dependency 
 dependency 
 groupId com.fasterxml.jackson.core /groupId 
 artifactId jackson-core /artifactId 
 version 2.7.4 /version 
 /dependency 
 dependency 
 groupId com.fasterxml.jackson.core /groupId 
 artifactId jackson-annotations /artifactId 
 version 2.7.0 /version 
 /dependency 
 dependency 
 groupId commons-fileupload /groupId 
 artifactId commons-fileupload /artifactId 
 version 1.3.1 /version 
 /dependency 
 dependency 
 groupId commons-io /groupId 
 artifactId commons-io /artifactId 
 version 2.4 /version 
 /dependency 
 dependency 
 groupId commons-codec /groupId 
 artifactId commons-codec /artifactId 
 version 1.9 /version 
 /dependency 
 /dependencies 
 build 
 finalName shiro-spring /finalName 
 /build 
 /project 

 

6.运转成果


 

能够看出,现已整合成功了。恳求后台回来正常的数据。
 

 

版权声明
本文来源于网络,版权归原作者所有,其内容与观点不代表乐橙lc8立场。转载文章仅为传播更有价值的信息,如采编人员采编有误或者版权原因,请与我们联系,我们核实后立即修改或删除。

猜您喜欢的文章