有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

Java Maven问题

这是我的pom。xml

`<?xml version="1.0" encoding="UTF-8"?>
<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/maven-v4_0_0.xsd">
   <modelVersion>4.0.0</modelVersion>
   <groupId>org.javaee7.batch</groupId>
   <artifactId>batch-samples</artifactId>
   <version>1.0-SNAPSHOT</version>
   <packaging>war</packaging>
   <name>Batch Applications for the Java Platform (JSR-352) Example</name>
   <description>Batch Applications for the Java Platform (JSR-352) Example</description>
   <url>http://jboss.org/jbossas</url>
   <licenses>
      <license>
         <name>Apache License, Version 2.0</name>
         <distribution>repo</distribution>
         <url>http://www.apache.org/licenses/LICENSE-2.0.html</url>
      </license> 
   </licenses>
   <properties>
      <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
      <version.jboss.maven.plugin>7.4.Final</version.jboss.maven.plugin>
      <version.jboss.spec.javaee.6.0>3.0.2.Final</version.jboss.spec.javaee.6.0>
      <version.war.plugin>2.1.1</version.war.plugin>
      <version.compiler.plugin>2.3.1</version.compiler.plugin>
      <!-- maven-compiler-plugin -->
      <maven.compiler.target>1.7</maven.compiler.target>
      <maven.compiler.source>1.7</maven.compiler.source>
      <version.jboss.bom>1.0.4.Final</version.jboss.bom>
   </properties>
   <dependencyManagement>
      <dependencies>
         <dependency>
            <groupId>org.jboss.spec</groupId>
            <artifactId>jboss-javaee-7.0</artifactId>
            <version>1.0.0.Beta2</version>
            <type>pom</type>
            <scope>import</scope>
         </dependency>
         <dependency>
            <groupId>org.jboss.bom</groupId>
            <artifactId>jboss-javaee-6.0-with-hibernate</artifactId>
            <version>${version.jboss.bom}</version>
            <type>pom</type>
            <scope>import</scope>
         </dependency>
      </dependencies>
   </dependencyManagement>
   <dependencies>
      <dependency>
         <groupId>org.hibernate.javax.persistence</groupId>
         <artifactId>hibernate-jpa-2.0-api</artifactId>
         <scope>provided</scope>
      </dependency>
      <dependency>
         <groupId>org.hibernate</groupId>
         <artifactId>hibernate-validator</artifactId>
         <scope>provided</scope>
         <exclusions>
            <exclusion>
               <groupId>org.slf4j</groupId>
               <artifactId>slf4j-api</artifactId>
            </exclusion>
         </exclusions>
      </dependency>
      <!-- Import the Batch API which is included in WildFly 8 -->
      <dependency>
         <groupId>org.jboss.spec.javax.batch</groupId>
         <artifactId>jboss-batch-api_1.0_spec</artifactId>
         <version>1.0.0.Final</version>
      </dependency>
      <!-- Import the CDI API -->
      <dependency>
         <groupId>javax.enterprise</groupId>
         <artifactId>cdi-api</artifactId>
         <scope>provided</scope>
      </dependency>
      <!-- Import the Common Annotations API (JSR-250) -->
      <dependency>
         <groupId>org.jboss.spec.javax.annotation</groupId>
         <artifactId>jboss-annotations-api_1.1_spec</artifactId>
         <scope>provided</scope>
      </dependency>
      <!-- Import the Servlet API -->
      <dependency>
         <groupId>org.jboss.spec.javax.servlet</groupId>
         <artifactId>jboss-servlet-api_3.0_spec</artifactId>
         <scope>provided</scope>
      </dependency>
   </dependencies>
   <build>
      <!-- Set the name of the war, used as the context root when the app is deployed -->
      <finalName>${project.artifactId}</finalName>
      <plugins>
         <plugin>
            <artifactId>maven-war-plugin</artifactId>
            <version>${version.war.plugin}</version>
            <configuration>
               <!-- Java EE 6 doesn't require web.xml, Maven needs to catch up! -->
               <failOnMissingWebXml>false</failOnMissingWebXml>
            </configuration>
         </plugin>
         <!-- JBoss AS plugin to deploy war -->
         <plugin>
            <groupId>org.jboss.as.plugins</groupId>
            <artifactId>jboss-as-maven-plugin</artifactId>
            <version>${version.jboss.maven.plugin}</version>
         </plugin>
         <!-- Compiler plugin enforces Java 1.6 compatibility and activates 
                annotation processors -->
         <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>${version.compiler.plugin}</version>
            <configuration>
               <source>${maven.compiler.source}</source>
               <target>${maven.compiler.target}</target>
            </configuration>
         </plugin>
      </plugins>
   </build>
</project>`

在eclipse中,我发现了以下错误: 1)

`Project build error: Non-resolvable import POM: Failure to transfer org.jboss.spec:jboss-javaee-7.0:pom:1.0.0.Beta2 from http://
 repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed  or updates are forced. Original error: Could not transfer artifact org.jboss.spec:jboss-javaee-7.0:pom:1.0.0.Beta2 from/to central (http:// repo.maven.apache.org/maven2): null to http://repo.maven.apache.org/maven2/org/jboss/spec/jboss-javaee-7.0/1.0.0.Beta2/jboss-javaee-7.0-1.0.0.Beta2.pom`

我在jboss-javaee-6.0-with-hibernate中遇到了同样类型的错误

2)我也得到了Project build error: 'dependencies.dependency.version' for org.hibernate.javax.persistence:hibernate-jpa-2.0-api:jar is missing.

3)项目生成错误:“依赖项”。附属国。组织版。hibernate:hibernate验证程序:jar丢失

4)项目生成错误:“依赖项”。附属国。javax版本。enterprise:cdi api:jar丢失

5)项目生成错误:“依赖项”。附属国。组织版。jboss。spec.javax。注释:jboss-annotations-api_1.1_spec:jar缺失

6)项目生成错误:“依赖项”。附属国。组织版。jboss。spec.javax。servlet:jboss-servlet-api_3.0_规范:jar缺失

7)

`Multiple annotations found at this line:
    - Plugin execution not covered by lifecycle configuration: org.apache.maven.plugins:maven-compiler-plugin:2.3.1:compile (execution: 
     default-compile, phase: compile)
    - CoreException: Could not calculate build plan: Plugin org.apache.maven.plugins:maven-compiler-plugin:2.3.1 or one of its dependencies 
     could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-compiler-plugin:jar:2.3.1: ArtifactResolutionException: 
     Failure to transfer org.apache.maven.plugins:maven-compiler-plugin:pom:2.3.1 from http://repo.maven.apache.org/maven2 was cached in the local 
     repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced. Original error: Could not transfer 
     artifact org.apache.maven.plugins:maven-compiler-plugin:pom:2.3.1 from/to central (http://repo.maven.apache.org/maven2): null to http://
     repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-compiler-plugin/2.3.1/maven-compiler-plugin-2.3.1.pom
    - Plugin execution not covered by lifecycle configuration: org.apache.maven.plugins:maven-compiler-plugin:2.3.1:testCompile (execution: 
     default-testCompile, phase: test-compile)`

请建议

完全错误:

`[INFO] Scanning for projects...
Downloading: http://repo.maven.apache.org/maven2/org/jboss/spec/jboss-javaee-7.0
/1.0.0.Beta2/jboss-javaee-7.0-1.0.0.Beta2.pom
Downloading: http://repo.maven.apache.org/maven2/org/jboss/bom/jboss-javaee-6.0-
with-hibernate/1.0.4.Final/jboss-javaee-6.0-with-hibernate-1.0.4.Final.pom
[ERROR] The build could not read 1 project -> [Help 1]
[ERROR]
[ERROR]   The project org.javaee7.batch:batch-samples:1.0-SNAPSHOT (D:\Projects\
SID\POC\chunk-csv-database\chunk-csv-database\pom.xml) has 7 errors
[ERROR]     Non-resolvable import POM: Could not transfer artifact org.jboss.spe
c:jboss-javaee-7.0:pom:1.0.0.Beta2 from/to central (http://repo.maven.apache.org
/maven2): repo.maven.apache.org @ line 31, column 22: Unknown host repo.maven.ap
ache.org -> [Help 2]
[ERROR]     Non-resolvable import POM: Could not transfer artifact org.jboss.bom
:jboss-javaee-6.0-with-hibernate:pom:1.0.4.Final from/to central (http://repo.ma
ven.apache.org/maven2): repo.maven.apache.org @ line 38, column 22: Unknown host
 repo.maven.apache.org -> [Help 2]
[ERROR]     'dependencies.dependency.version' for org.hibernate.javax.persistenc
e:hibernate-jpa-2.0-api:jar is missing. @ line 48, column 19
[ERROR]     'dependencies.dependency.version' for org.hibernate:hibernate-valida
tor:jar is missing. @ line 53, column 19
[ERROR]     'dependencies.dependency.version' for javax.enterprise:cdi-api:jar i
s missing. @ line 71, column 19
[ERROR]     'dependencies.dependency.version' for org.jboss.spec.javax.annotatio
n:jboss-annotations-api_1.1_spec:jar is missing. @ line 77, column 19
[ERROR]     'dependencies.dependency.version' for org.jboss.spec.javax.servlet:j
boss-servlet-api_3.0_spec:jar is missing. @ line 83, column 19
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e swit
ch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please rea
d the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/ProjectBuildin
gException
[ERROR] [Help 2] http://cwiki.apache.org/confluence/display/MAVEN/UnresolvableMo
delException`

共 (1) 个答案

  1. # 1 楼答案

    从stacktrace:

    Unknown host repo.maven.apache.org
    

    不管其他评论如何,如果你无法解决中央回购协议,你将无法下载依赖项

    你能从命令行ping这个吗(或者至少获得一个IP)