测试类用的junit,在eclipse中执行ok,在maven编译就挂
Error MessageTest class should have exactly one public constructor
Stacktracejava.lang.Exception: Test class should have exactly one public constructorat org.junit.runners.BlockJUnit4ClassRunner.validateOnlyOneConstructor(BlockJUnit4ClassRunner.java:136)at org.junit.runners.BlockJUnit4ClassRunner.validateConstructor(BlockJUnit4ClassRunner.java:125)at org.junit.runners.BlockJUnit4ClassRunner.collectInitializationErrors(BlockJUnit4ClassRunner.java:114)
解决办法,在pom.xml中的maven-surefire-plugin配置中增加以下内容
**/*$*.java
<plugin><groupId>org.apache.maven.pluginsgroupId><artifactId>maven-surefire-pluginartifactId><configuration><includes><include>**/*Test*.javainclude>includes><excludes><include>**/test/**/*Test*.javainclude><include>**/servicetest/**/*.javainclude><include>**/*$*.javainclude>excludes><testFailureIgnore>truetestFailureIgnore><argLine>-Xmx1024margLine>configuration>
应该是junit和maven的surefire plugin不兼容导致的