Maven: 包 net.jcip.annotations 不存在
Maven: package net.jcip.annotations does not exist
我想在我的 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 代码中使用 @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>