ssm三大框架整合

阅读更多

一个简单的spring,springmvc,mybatis三大框架整合

1.spring整合springmvc

 




	
	
		
		
		
	
	
		
			
				text/html;charset=UTF-8
			
		
	
	
		
			
				
			
		
	
	
		
		
		
	

	
		
		
		
	

	

	
	
  

 2.web.xml配置文件配置( 需要注意spring的配置文件和spirngmvc的配置文件分开加载 )

 

 


	Archetype Created Web Application
	
		contextConfigLocation
		
			classpath:spring/spring.xml
			classpath:spring/spring-mybatis.xml
		
	
	
		org.springframework.web.context.ContextLoaderListener
	
	
		org.springframework.web.util.IntrospectorCleanupListener
	
	
		dispatcherServlet
		org.springframework.web.servlet.DispatcherServlet
		
                
			contextConfigLocation
			classpath:spring/spring-mvc.xml
		
		1
	
	
		dispatcherServlet
		/
	
	
		SpringMVC
		/
	
	
		encodingFilter
		org.springframework.web.filter.CharacterEncodingFilter
		true
		
			encoding
			UTF-8
		
	
	
		encodingFilter
		/*
	

 3.spring整合mybatis( 需要注意使用mapper扫描时,扫描的包的位置,此处我需要在mapper接口在加一个自定义注解,不然貌似有问题。 )



	
		
		
		
		
		
		
		
		
		
		
		
		
	

	
		
		
	

	
		
		
		
	

	
		
	

	
  

 4.spring的一个配置文件



	
	
		
	
	
	
		
		
			
				classpath:jdbc.properties
			
		
	
	
	
  

5.pom配置文件



	4.0.0
	
		com.huan.shiro
		shiro-parent
		0.0.1-SNAPSHOT
	
	shiro-spring
	war
	shiro-spring Maven Webapp
	http://maven.apache.org

	
		4.2.7.RELEASE
		1.7.21
	

	
		
			junit
			junit
		
		
			org.springframework
			spring-core
			4.2.7.RELEASE
		
		
			org.springframework
			spring-test
			4.2.7.RELEASE
		
		
			org.springframework
			spring-context
			4.2.7.RELEASE
		
		
			org.springframework
			spring-context-support
			4.2.7.RELEASE
		
		
			org.springframework
			spring-tx
			4.2.7.RELEASE
		
		
			org.springframework
			spring-jdbc
			4.2.7.RELEASE
		
		
			org.springframework
			spring-web
			4.2.7.RELEASE
		
		
			org.springframework
			spring-webmvc
			4.2.7.RELEASE
		
		
			org.springframework
			spring-expression
			4.2.7.RELEASE
		
		
			org.springframework
			spring-aop
			4.2.7.RELEASE
		

		
			org.mybatis
			mybatis
			3.3.0
		
		
			org.mybatis
			mybatis-spring
			1.2.2
		

		
		
			org.aspectj
			aspectjrt
			1.7.4
		
		
			org.aspectj
			aspectjweaver
			1.7.4
		
		
			cglib
			cglib
			3.1
		
		

		
			org.apache.shiro
			shiro-core
		
		
			org.apache.shiro
			shiro-web
		
		
			org.apache.shiro
			shiro-spring
			${shiro.version}
		

		
			com.alibaba
			druid
			1.0.19
		
		
			mysql
			mysql-connector-java
			5.1.37
		
		
			taglibs
			standard
			1.1.2
			jar
		
		
			javax.servlet
			jstl
			1.2
			jar
		
		
			javax.servlet
			javax.servlet-api
			provided
		
		
			javax.servlet.jsp
			jsp-api
			2.2
			provided
		
		
			org.slf4j
			slf4j-api
		
		
			org.slf4j
			slf4j-log4j12
			${slf4j.version}
		
		
		
			org.slf4j
			jcl-over-slf4j
		
		
		
			org.slf4j
			jul-to-slf4j
			${slf4j.version}
		
		
			com.fasterxml.jackson.core
			jackson-databind
			2.7.4
		
		
			com.fasterxml.jackson.core
			jackson-core
			2.7.4
		
		
			com.fasterxml.jackson.core
			jackson-annotations
			2.7.0
		
		
			commons-fileupload
			commons-fileupload
			1.3.1
		
		
			commons-io
			commons-io
			2.4
		
		
			commons-codec
			commons-codec
			1.9
		
	
	
		shiro-spring
	

 

6.运行结果


ssm三大框架整合_第1张图片

 

可以看出,已经整合成功了。请求后台返回正常的数据。
 

 

  • ssm三大框架整合_第2张图片
  • 大小: 204.1 KB
  • 查看图片附件

你可能感兴趣的:(spring,springmc,mybatis)