In my maven project I am using a dependency of type test-jar which m2e does not like and gives the following warning.
在我的maven项目中,我使用的是类型为test-jar的依赖项,m2e不喜欢并给出以下警告。
"Dependency to project foo with type test-jar is not fully supported. Classpath and/or deployment issues might arise. Try Maven->Disable Workspace"
“不完全支持使用类型test-jar对项目foo的依赖。可能会出现类路径和/或部署问题。尝试Maven->禁用工作区”
Why does this problem arise and why would disabling workspace resolution fix it?
为什么会出现此问题以及为什么禁用工作区解析会解决此问题?
2 个解决方案
#1
3
The problem with test-jar is in Eclipse see Bug 365419 - Classpath for Integration Test
test-jar的问题在于Eclipse,请参阅Bug 365419 - Integration Test的Classpath
#2
3
I have tried making this warning go away with the hack below, however it has a side effect of making it impossible to run tests from eclipse because of the class-path for the tests in eclipse when running code does not get set properly. I am posting here in hopes that some one can improve this hack and make it work.
我已经尝试使用下面的hack来消除此警告,但它有副作用使得无法运行eclipse中的测试,因为在运行代码时,eclipse中的测试的类路径未正确设置。我在这里发帖,希望有人可以改进这个黑客并让它发挥作用。
Create a profile in the pom file is turned off when in eclipse but automatically turns on when running maven outside eclipse.
在eclipse中创建pom文件中的配置文件时会关闭,但在eclipse之外运行maven时会自动打开。
<profiles>
<profile>
<id>test-jars</id>
<activation>
<property>
<name>!m2e.version</name>
</property>
</activation>
<dependencies>
<dependency>
<groupId>com.example</groupId>
<artifactId>foo</artifactId>
<version>${project.version}</version>
<type>test-jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.example</groupId>
<artifactId>bar</artifactId>
<version>${project.version}</version>
<type>test-jar</type>
<scope>test</scope>
</dependency>
</dependencies>
</profile>
</profiles>
Inside eclipse the m2e.version property is defined so the test-jar dependencies are ignored by m2e and no warning is generated. However, when running maven on the command line the profile activates because there is no m2e.version property and so the warning goes away.
在eclipse中定义了m2e.version属性,因此m2e忽略了test-jar依赖项,并且没有生成警告。但是,在命令行上运行maven时,配置文件会激活,因为没有m2e.version属性,因此警告消失。
#1
3
The problem with test-jar is in Eclipse see Bug 365419 - Classpath for Integration Test
test-jar的问题在于Eclipse,请参阅Bug 365419 - Integration Test的Classpath
#2
3
I have tried making this warning go away with the hack below, however it has a side effect of making it impossible to run tests from eclipse because of the class-path for the tests in eclipse when running code does not get set properly. I am posting here in hopes that some one can improve this hack and make it work.
我已经尝试使用下面的hack来消除此警告,但它有副作用使得无法运行eclipse中的测试,因为在运行代码时,eclipse中的测试的类路径未正确设置。我在这里发帖,希望有人可以改进这个黑客并让它发挥作用。
Create a profile in the pom file is turned off when in eclipse but automatically turns on when running maven outside eclipse.
在eclipse中创建pom文件中的配置文件时会关闭,但在eclipse之外运行maven时会自动打开。
<profiles>
<profile>
<id>test-jars</id>
<activation>
<property>
<name>!m2e.version</name>
</property>
</activation>
<dependencies>
<dependency>
<groupId>com.example</groupId>
<artifactId>foo</artifactId>
<version>${project.version}</version>
<type>test-jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.example</groupId>
<artifactId>bar</artifactId>
<version>${project.version}</version>
<type>test-jar</type>
<scope>test</scope>
</dependency>
</dependencies>
</profile>
</profiles>
Inside eclipse the m2e.version property is defined so the test-jar dependencies are ignored by m2e and no warning is generated. However, when running maven on the command line the profile activates because there is no m2e.version property and so the warning goes away.
在eclipse中定义了m2e.version属性,因此m2e忽略了test-jar依赖项,并且没有生成警告。但是,在命令行上运行maven时,配置文件会激活,因为没有m2e.version属性,因此警告消失。