Maven2默认的Junit是3.8.1,因为以前用的一直是Junit4,感觉很不习惯。在google中搜一下,还真找到了Maven的Junit4的插件。http://wiki.unto.net/Maven_JUnit4_plugin,不敢独享。
只要在POM.XML中加入下面的代码。运行mvn test 就可以了。
<
dependencies
>
<
dependency
>
<
groupId
>
junit
</
groupId
>
<
artifactId
>
junit
</
artifactId
>
<
version
>
4.0
</
version
>
<
scope
>
test
</
scope
>
</
dependency
>
</
dependencies
>
<
build
>
<
plugins
>
<
plugin
>
<
artifactId
>
maven-compiler-plugin
</
artifactId
>
<
configuration
>
<
source
>
1.5
</
source
>
<
target
>
1.5
</
target
>
</
configuration
>
</
plugin
>
<
plugin
>
<
groupId
>
net.unto.maven.plugins
</
groupId
>
<
artifactId
>
maven-junit4-plugin
</
artifactId
>
<
version
>
1.0-SNAPSHOT
</
version
>
<
executions
>
<
execution
>
<
phase
>
test
</
phase
>
<
goals
>
<
goal
>
test
</
goal
>
</
goals
>
</
execution
>
</
executions
>
</
plugin
>
</
plugins
>
</
build
>
<
pluginRepositories
>
<
pluginRepository
>
<
id
>
unto.net
</
id
>
<
url
>
http://repository.unto.net/maven/
</
url
>
<
releases
>
<
updatePolicy
>
daily
</
updatePolicy
>
<
checksumPolicy
>
warn
</
checksumPolicy
>
</
releases
>
<
snapshots
>
<
updatePolicy
>
daily
</
updatePolicy
>
<
checksumPolicy
>
warn
</
checksumPolicy
>
</
snapshots
>
</
pluginRepository
>
</
pluginRepositories
>
只要在POM.XML中加入下面的代码。运行mvn test 就可以了。















































