2019独角兽企业重金招聘Python工程师标准>>>
一、安装java环境(略)
这方面资料很多
我的环境是JDK6+eclipse4 j2ee版,自带Maven等一些插件
二、安装Maven(略)
Maven安装简单装好后修改 根目录/conf/settings.xml,配置好maven库目录
打开eclipse windows-preference-maven-userSettings-global settings选择maven安装目录的settings.xml文件
点击maven在主配置上勾选,这时maven会下载index可能会很慢。需要等等
三、创建maven工程
点击Eclipse菜单栏File->New->Ohter->Maven->选择项目目录->next->选择项目类型
搜索web,创建项目->next
填写groupId和artifact Id->finish
项目配置
右击项目-new
创建如下几个文件
配置build path
分别修改输出路径为
src/main/resources 对应 target/classes
src/main/java 对应 target/classes
src/test/resources 对应 target/test-classes
src/test/java 对应 target/test-classes
设置JDK版本
设置部署程序集(Web Deployment Assembly)
把两个test目录去掉!!!
到此项目算是部署完成了。如果有其他问题百度一下吧!!
三 spring mvc+spring+mybatis配置
首先pom.xml文件内容
4.0.0
com.xxl.maven_web
xxl_maven_web
war
0.0.1-SNAPSHOT
xxl_maven_web Maven Webapp
http://maven.apache.org
xxl_maven_web
org.springframework
spring-web
4.0.6.RELEASE
junit
junit
4.11
test
javax.servlet
servlet-api
2.5
org.springframework
spring-aspects
4.0.6.RELEASE
org.springframework
spring-webmvc
4.0.6.RELEASE
org.springframework
spring-context-support
4.0.6.RELEASE
org.freemarker
freemarker
2.3.20
commons-logging
commons-logging
1.2
commons-lang
commons-lang
2.6
org.springframework
spring-mock
2.0.8
test
log4j
log4j
1.2.14
org.mybatis
mybatis
3.2.7
org.mybatis
mybatis-spring
1.2.2
mysql
mysql-connector-java
5.1.32
org.springframework
spring-tx
4.0.6.RELEASE
org.springframework
spring-jdbc
4.0.6.RELEASE
org.apache.commons
commons-collections4
4.0
commons-dbcp
commons-dbcp
1.4
commons-pool
commons-pool
1.6
org.springframework
spring-test
4.0.6.RELEASE
test
web.xml
webAppRootKey
maven.xxl_web.root
org.springframework.web.util.Log4jConfigListener
CharacterEncodingFilter
org.springframework.web.filter.CharacterEncodingFilter
encoding
UTF-8
forceEncoding
true
CharacterEncodingFilter
/*
contextConfigLocation
classpath:applicationContext-*.xml
dispatcher
org.springframework.web.servlet.DispatcherServlet
contextConfigLocation
/WEB-INF/dispatcher-servlet.xml
1
dispatcher
*.html
org.springframework.web.context.ContextLoaderListener
/login.jsp
dispatcher-servlet.xml
10
zh_CN
yyyy-MM-dd HH:mm:ss
yyyy-MM-dd
#.##
applicationContext-bean.xml
mybaitis.xml
单元测试代码
package xxl.test.service;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.transaction.TransactionConfiguration;
import org.springframework.transaction.annotation.Transactional;
import com.xxl.app.base.service.IIndexService;
@ContextConfiguration(locations={"classpath:applicationContext-bean.xml"})
@RunWith(SpringJUnit4ClassRunner.class)
@Transactional
//如果是true不会改变数据库数据,如果是false会改变数据
@TransactionConfiguration(transactionManager="transactionManager",defaultRollback=true)
public class IndexService {
@Autowired
private IIndexService indexService;
@Test
public void TestIndex(){
indexService.doIndex();
}
}