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
<?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: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>
<!--配置代理模式為cglib -->
<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>
<!--配置mapper包掃描 -->
<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 -->
<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>
<!--配置切面 -->
<!--配置切點bean -->
<!--配置通知bean -->
<!--織入形成切面 -->
<!--配置其他bean -->
</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
<?xml version="1.0" encoding="UTF-8"?>
<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註解驅動 -->
<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">sizeLimit</prop>
</props>
</property>
</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_3_0.xsd" id="WebApp_ID" version="3.0">
<!--配置Spring -->
<!--配置applicationContext,xml的路徑 -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:applicationContext.xml</param-value>
</context-param>
<!--配置監聽器 -->
<listener><listener-class>org.springframework.web.context.ContextLoaderListener</listener-class></listener>
<!--配置SpringMVC 的servlet -->
<servlet>
<servlet-name>servlet123</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<!--配置Spring MVC 的配置檔案路徑 -->
<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>servlet123</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<!--配置編碼過濾器 -->
<filter>
<filter-name>encoding</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>
<init-param>
<param-name>forceEncoding</param-name>
<param-value>true</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>encoding</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>
相關文章
- 用IDEA搭建SSM框架IdeaSSM框架
- Day73 SSM專案 搭建框架SSM框架
- SSM框架SSM框架
- SSM-框架搭建-tank後臺學習系統SSM框架
- ssm專案的搭建:使用到框架 spring springmvc mybatisSSM框架SpringMVCMyBatis
- 最好的 Go 框架:沒有框架?Go框架
- SSM框架整合SSM框架
- 整合SSM框架SSM框架
- ssm框架理解SSM框架
- SSM框架的整合SSM框架
- ssm框架整合筆記SSM框架筆記
- SSM框架整合流程SSM框架
- SSM框架整合開發SSM框架
- 「SSM框架最新專案」搭建個人部落格例項講解教程SSM框架
- SSM之Spring框架--->>墨盒案例SSMSpring框架
- SSM框架整合(配置檔案)SSM框架
- SSM框架pom配置檔案SSM框架
- 搭建一個SSM專案SSM
- SpringMVC(3)- 校驗框架、SSM整合SpringMVC框架SSM
- 【Java】SSM框架整合 附原始碼JavaSSM框架原始碼
- SSM框架常見面試題SSM框架面試題
- idea搭建簡易ssm專案IdeaSSM
- IDEA使用maven搭建SSM框架整合專案(超級詳細,值得一看)IdeaMavenSSM框架
- SSM框架整合——書籍管理系統SSM框架
- SSM三大框架整合詳細教程SSM框架
- SSM整合之CRUD環境搭建整合SSM
- idea ssm maven專案搭建筆記IdeaSSMMaven筆記
- Java SSM練手小專案-手把手帶你搭建一個基於SSM框架的人力資源管理後臺系統JavaSSM框架
- ssm框架整合redis(demo)---通過cache方式SSM框架Redis
- SSM框架實現分頁查詢例子SSM框架
- laravel框架的程式碼加密有沒有什麼好的方法啊?Laravel框架加密
- 沒有程式碼基礎,如何搭建攝影網站網站
- 基於SSM框架的簡單問答社群SSM框架
- SSM(Spring-MyBatis-SpringMVC)框架整合【完整版】SSMMyBatisSpringMVC框架
- 一起學習SSM框架之SpringMVC(五)SSM框架SpringMVC
- 關於SSM框架的一個簡單DemoSSM框架
- SSM框架相關基礎面試題整理SSM框架面試題
- SSM 框架快速整合例項--學生查詢SSM框架