gpt4 book ai didi

java - Maven: 包 net.jcip.annotations 不存在

转载 作者:行者123 更新时间:2023-11-30 06:14:34 26 4
gpt4 key购买 nike

我想在我的 Java 代码中使用 @net.jcip.annotations.NotThreadSafe。我试图导入它是项目的 pom.xml 中的依赖项,如下所示。但是,我仍然收到错误消息:我的导入有问题吗?

包 net.jcip.annotations 不存在

  <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.18</version>
<dependencies>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-junit47</artifactId>
<version>2.18</version>
</dependency>
<dependency>
<groupId>net.jcip</groupId>
<artifactId>jcip-annotations</artifactId>
<version>1.0</version>
</dependency>
</dependencies>
<configuration>
{...}
</configuration>
</plugin>

最佳答案

如果你像上面那样做,你只是将依赖添加到 maven-surefire-plugin 的类路径中,这不是你想要的。你必须像这样在你的 pom 中提供它:

<project...>
<dependencies>
<dependency>
<groupId>net.jcip</groupId>
<artifactId>jcip-annotations</artifactId>
<version>1.0</version>
</dependency>
...
</dependencies>

</project>

此外,鉴于对 surefire-juni47 的依赖不是必需的,因为 surefire 插件会自行处理。所以这看起来像这样:

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.18</version>
<configuration>
{...}
</configuration>
</plugin>

关于java - Maven: 包 net.jcip.annotations 不存在,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30094198/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com