SSM框架详细整合教程(Spring+SpringMVC+MyBatis)

《一线大厂Java面试题解析+核心总结学习笔记+最新讲解视频+实战项目源码》点击传送门,即可获取!

#可以灵活地指定日志输出格式,下面一行是指定具体的格式

log4j.appender.Console.layout = org.apache.log4j.PatternLayout

log4j.appender.Console.layout.ConversionPattern=[%c] - %m%n

#文件大小到达指定尺寸的时候产生一个新的文件

log4j.appender.File = org.apache.log4j.RollingFileAppender

#指定输出目录

log4j.appender.File.File = logs/ssm.log

#定义文件最大大小

log4j.appender.File.MaxFileSize = 10MB

输出所以日志,如果换成DEBUG表示输出DEBUG以上级别日志

log4j.appender.File.Threshold = ALL

log4j.appender.File.layout = org.apache.log4j.PatternLayout

log4j.appender.File.layout.ConversionPattern =[%p] [%d{yyyy-MM-dd HH:mm:ss}][%c]%m%n

spring-dao.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-3.1.xsd

http://www.springframework.org/schema/context

http://www.springframework.org/schema/context/spring-context-3.1.xsd

http://www.springframework.org/schema/mvc

http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd">

spring-db.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-3.1.xsd

http://www.springframework.org/schema/context

http://www.springframework.org/schema/context/spring-context-3.1.xsd

http://www.springframework.org/schema/mvc

http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd">

spring-tx.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:aop=“http://www.springframework.org/schema/aop”

xmlns:tx=“http://www.springframework.org/schema/tx”

xmlns:mvc=“http://www.springframework.org/schema/mvc”

xsi:schemaLocation="http://www.springframework.org/schema/beans

http://www.springframework.org/schema/beans/spring-beans-3.1.xsd

http://www.springframework.org/schema/context

http://www.springframework.org/schema/context/spring-context-3.1.xsd

http://www.springframework.org/schema/aop

http://www.springframework.org/schema/aop/spring-aop-3.1.xsd

http://www.springframework.org/schema/tx

http://www.springframework.org/schema/tx/spring-tx-3.1.xsd">

<bean id=“transactionManager”

class=“org.springframework.jdbc.datasource.DataSourceTransactionManager”>

aop:config

<aop:pointcut id=“allServiceMethod” expression=“execution(* com.chillax.service..(…))”/>

<aop:advisor pointcut-ref=“allServiceMethod” advice-ref=“TxAdvice” />

</aop:config>

<tx:advice id=“TxAdvice” transaction-manager=“transactionManager”>

tx:attributes

<tx:method name=“*” propagation=“REQUIRED” rollback-for=“java.lang.Exception”/>

</tx:attributes>

</tx:advice>

3、在WEB-INF文件夹下添加/修改以下配置文件


spring-mvc.xml

<?xml version="1.0" encoding="UTF-8"?>

<

  • 11
    点赞
  • 20
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
SSM是指Spring+SpringMVC+MyBatis的集成开发环境。MySQL是一个关系型数据库管理系统,用于存储和管理数据。Maven是一个项目管理和构建工具,可以自动下载所需的类库和插件,并管理项目的依赖关系。Idea是一个Java集成开发环境(IDE),提供了开发、调试和部署Java代码的工具。 在SSM MySQL Maven Idea MyBatis Spring SpringMVC的集成开发环境下,我们可以通过Maven构建项目,引入相应的依赖库。Idea提供了可视化的界面,方便我们进行开发和调试工作。 首先,我们可以使用Maven来管理项目的依赖。在pom.xml文件中添加相应的依赖,Maven会自动下载并引入到项目中。 其次,我们可以使用Idea创建Spring项目,并配置相关的配置文件。在Idea的配置界面中,我们可以设置项目的数据库连接信息和配置MyBatis的相关内容。 然后,我们可以使用MyBatis来操作MySQL数据库。在MyBatis的mapper文件中编写SQL语句,并在Spring中配置相应的bean,使其可以与数据库进行交互。 此外,我们还可以使用SpringMVC来开发Web应用。在SpringMVC中,我们可以通过配置相应的请求映射和控制器来处理请求,并返回相应的结果。 最后,通过整合SpringSpringMVCMyBatis,我们可以实现业务逻辑与数据库的交互,并通过Maven进行项目构建和管理。这样,我们就可以在SSM MySQL Maven Idea MyBatis Spring SpringMVC的集成开发环境中进行基于这些框架和工具的开发工作了。 总之,掌握SSM MySQL Maven Idea MyBatis Spring SpringMVC的集成开发环境,意味着我们可以利用这些强大工具和框架来进行Java开发,并能够高效地开发出优质的Web应用程序。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值