SS2H框架环境的创建(Spring ,Struts2,hibernate)--由maven管理jar包

1.建立一个maven web项目 .

1.在main中右键建立一个folder 命名为java , 此时上面会添加一个src/main/java的文件夹 在这里面建包 写代码。
2.将jdk编译器改为1.8 同时将javacompiler改为1.8 与之匹配。
3.添加需要用到的jar包。 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
4.0.0
com.lin
maven111
war
0.0.1-SNAPSHOT
maven111 Maven Webapp
http://maven.apache.org


junit
junit
4.12
test


org.springframework
spring-context
4.3.7.RELEASE


org.springframework
spring-test
4.3.7.RELEASE


org.aspectj
aspectjrt
1.8.10


org.aspectj
aspectjweaver
1.8.10


org.hibernate
hibernate-core
5.2.8.FINAL


mysql
mysql-connector-java
5.1.40



org.apache.commons
commons-dbcp2
2.1.1



org.springframework
spring-orm
4.3.7.RELEASE



org.apache.struts
struts2-core
2.5.10



org.apache.struts
struts2-json-plugin
2.5.10



org.apache.struts
struts2-spring-plugin
2.5.10



org.apache.struts
struts2-convention-plugin
2.5.10



org.mockito
mockito-all
1.10.19



org.springframework
spring-web
4.3.7.RELEASE



javax.servlet
javax.servlet-api
3.1.0
provided



javax.servlet.jsp
javax.servlet.jsp-api
2.3.1
provided



javax.servlet
jstl
1.2



maven111



org.apache.maven.plugins
maven-compiler-plugin

1.8
1.8




2.在src/main/resources处建立两个file 取名struts.xml app.xml

SS2H框架环境的创建(Spring ,Struts2,hibernate)--由maven管理jar包_第1张图片
Paste_Image.png

1.web.xml中的配置如下;
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd" >



contextConfigLocation
classpath:applicationContext.xml
(这里的classpath:后面的名字必须与自己取得名字对应 比如app.xml)



struts2
org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter


struts2
/*


org.springframework.web.context.ContextLoaderListener

2.app.xml中的配置


xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop"
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/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
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop.xsd"
default-autowire="byType">







class="org.apache.commons.dbcp2.BasicDataSource">






class="org.springframework.orm.hibernate5.HibernateTransactionManager" />






com.lin.myweb.model.Goods




hibernate.dialect=org.hibernate.dialect.MySQLDialect
hibernate.show_sql=true
hibernate.format_sql=true

hibernate.hbm2ddl.auto=update




3.struts.xml中的配置


"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.5.dtd">







/index.jsp


index


你可能感兴趣的:(SS2H框架环境的创建(Spring ,Struts2,hibernate)--由maven管理jar包)