这是pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.sample</groupId>
<artifactId>whiteboard</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>
<name>whiteboard</name>
<properties>
<endorsed.dir>${project.build.directory}/endorsed</endorsed.dir>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<netbeans.hint.deploy.server>gfv3ee6</netbeans.hint.deploy.server>
</properties>
<repositories>
<repository>
<id>java.net-promoted</id>
<url>https://maven.java.net/content/groups/promoted/</url>
</repository>
</repositories>
<build>
<finalName>whiteboard</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.1.1</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>javax.websocket</groupId>
<artifactId>javax.websocket-api</artifactId>
<version>1.0</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>javax.json-api-1.0</groupId>
<artifactId>javax.json-api-1.0</artifactId>
<version>2.8</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
</dependency>
</dependencies>
</project>
我正在使用两个jar文件/javax.json-api-1.0-2.8.jar和javax.websocket-api-1.0.jar。 当我运行我的项目时,发生以下异常
无法在项目白板上执行目标:无法解析项目org.sample的依赖项:whiteboard:war:1.0-SNAPSHOT:无法收集[javaee-api:javax:jar:7.0-b77(compile)的依赖项, javax.websocket:javax.websocket-api:jar:1.0(编译),javax.json-api-1.0:javax.json-api-1.0:jar:2.8(编译)]:无法读取javaee-api的工件描述符:javax:jar:7.0-b77:无法传输工件javaee-api:javax:pom:7.0-b77 from / to central(http://repo.maven.apache.org/maven2):repo.maven.apache.org:未知主机repo.maven。 apache.org - &gt; [帮助1]
答案 0 :(得分:2)
在将它添加到pom.xml之前,请检查您要使用的jar的版本号,组ID和工件ID。它将作为该jar的元数据xml的一部分。 http://search.maven.org/remotecontent?filepath=javax/json/javax.json-api/maven-metadata.xml
<dependency>
<groupId>javax.json</groupId>
<artifactId>javax.json-api</artifactId>
<version>1.0</version>
<type>jar</type>
</dependency>