根据上一篇文章构建开发环境后,可以着手构建SSM框架的开发体系结构
1、打开eclipse
2、新的动态web项目
3 .复制项目WebContent目录下WEB-INF目录下lib目录下所需的jar包。 以下是jar包的下载位置。
4、在WEB-INF目录下创建新的web.xml文件,并复制以下代码:
xmlns=' http://xmlns.JCP.org/XML/ns/javaee '
xsi :方案位置=' http://xmlns.JCP.org/XML/ns/javaee
3358 xmlns.JCP.org/XML/ns/javaee/we B- app _3_1. xsd '
id='WebApp_ID' version='3.1 '
上下文配置
class path : application context.XML
org.spring framework.web.context.contextloaderlistener
编码
org.spring framework.web.filter.characterencodingfilter
编码
UTF-8
编码
*.action
crm
org.spring framework.web.servlet.dispatcher servlet
上下文配置
class path : spring MVC-config.XML
1
crm
*.action
index.html
5、在WebContent目录下创建新的index.html进行测试
6 .在Java Resources目录下创建新的源文件夹。 注意它是源文件夹! 重命名为config
7、在config源文件夹下新建以下配置文件
application context.XML (请注意com.it heima.Dao和com.itheima.service为您定制的软件包) )。
xmlns 3360 xsi=' http://www.w3.org/2001/XML架构-instance '
xmlns : AOP=' http://www.spring framework.org/schema/AOP '
xmlns : tx=' http://www.spring framework.org/schema/tx '
xmlns 3360 context=' http://www.spring framework.org/schema/context '
xsi :方案位置=' http://www.spring framework.org/schema/beans
33558 www.spring framework.org/schema/beans/spring-beans-4.3.xsd
33558 www.spring framework.org/schema/tx
33558 www.spring framework.org/schema/tx/spring-tx-4.3.xsd
33558 www.spring framework.org/schema/context
33558 www.spring framework.org/schema/context/spring-context-4.3.xsd
33558 www.spring framework.org/schema/AOP
33558 www.spring framework.org/schema/AOP/spring-AOP-4.3.xsd '
class=' org.Apache.com mons.dbcp2. basic data source '
' org.spring framework.JDBC.data source.datasourcetransactionmanager '
class=' org.my batis.spring.sqlsessionfactorybean '
db.properties
JDBC.driver=com.MySQL.JDBC.driver
JDBC.URL=JDBC : MySQL ://localhost :3306/my batis
jdbc.username=root
jdbc.password=123456
jdbc.maxTotal=30
jdbc.maxIdle=10
jdbc.initialSize=5
log4j.properties
#全局记录配置
log4j.rootLogger=ERROR,stdout
#我的电池日志配置.
log4j.logger.com.itheima=DEBUG
#控制台输出.
log4j.appender.stdout=org.Apache.log4j.console appender
log4j.appender.stdout.layout=org.Apache.log4j.pattern layout
log4j.appender.stdout.layout.conversion pattern=% 5p [ % t ]-% m % n
mybatis-config.xml
/p
' http://my batis.org/dtd/my batis-3-config.dtd '
springmvc-config.xml
xmlns 3360 xsi=' http://www.w3.org/2001/XML架构-instance '
xmlns : MVC=' http://www.spring framework.org/schema/MVC '
xmlns 3360 context=' http://www.spring framework.org/schema/context '
xmlns : tx=' http://www.spring framework.org/schema/tx '
xsi :方案位置=' http://www.spring framework.org/schema/beans
33558 www.spring framework.org/schema/beans/spring-beans-4.3.xsd
33558 www.spring framework.org/schema/MVC
33558 www.spring framework.org/schema/MVC/spring-MVC-4.3.xsd
33558 www.spring framework.org/schema/context
33558 www.spring framework.org/schema/context/spring-context-4.3.xsd '
' org.spring framework.web.servlet.view.internalresourceviewresolver '
8、单击eclipse工具栏上方的Window-Preferences,在弹出的框中找到服务器,单击服务器下方的Runtime Environments,然后单击Add
9、右键单击项目,选择在服务器上启动,启动后,如果成功显示index.html页面,则配置成功。 如果报告了错误,请自己去百度。