您只能指定配置文件并仅在 Eclipse 中激活它。
示例(假设您的问题是由于依赖而引起的groovy-all
):
<profiles>
<profile>
<id>eclipse-groovy-no-junit5</id>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>${groovy.groupId}</groupId>
<artifactId>groovy-all</artifactId>
<version>${groovy.version}</version>
<type>pom</type>
<exclusions>
<exclusion>
<groupId>${groovy.groupId}</groupId>
<artifactId>groovy-test-junit5</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
</dependencyManagement>
</profile>
</profiles>
Run Code Online (Sandbox Code Playgroud)
然后去
Project -> Properties -> Maven -> Active Maven Profiles
并指定配置文件名称eclipse-groovy-no-junit5
。
备注:groovy.groupId
被设置为(它是一个变量,因为它将在 4.x 中org.codehaus.groovy
被替换)并被设置为.org.apache.groovy
groovy.version
3.0.8
如果你想更详细一点,你可以添加...
<activation>
<activeByDefault>false</activeByDefault>
</activation>
Run Code Online (Sandbox Code Playgroud)
...但无论如何这是默认的。