JBoss AS 7的Maven构建失败Hello world示例

gva*_*nto 6 java jboss maven

我试着按照这个教程:https: //docs.jboss.org/author/display/AS7/Helloworld+quickstart

但是在遵循清理+构建包的简单指令时会出现构建错误:

gert @ gert-VirtualBox:〜/ workspace/jboss-eap-6.1.0.GA-quickstarts/helloworld $ mvn clean package [INFO]扫描项目... [ERROR]构建无法读取1个项目 - > [帮助1] [ERROR] [ERROR]项目org.jboss.as.quickstarts:jboss-as-helloworld:7.1.2-SNAPSHOT(/home/gert/workspace/jboss-eap-6.1.0.GA-quickstarts/helloworld /pom.xml)有4个错误[错误]不可解析导入POM:未能在http:// repo中找到org.jboss.spec:jboss-javaee-6.0:pom:3.0.2.Final-redhat-3 . maven.apache.org/maven2缓存在本地存储库中,在中心的更新间隔过去或强制更新后,将不再重新尝试解决方案@第68行,第25列 - > [帮助2]

我根本没有编辑过pom.xml文件 - 这不应该只是工作吗?

我用Google搜索并发现了这个:https://community.jboss.org/message/762371#762371 但我似乎没有设置文件在任何地方?

请,任何帮助将不胜感激!

gvanto

POM文件:

http://maven.apache.org/maven-v4_0_0.xsd"> 4.0.0

<groupId>org.jboss.as.quickstarts</groupId>
<artifactId>jboss-as-helloworld</artifactId>
<version>7.1.2-SNAPSHOT</version>
<packaging>war</packaging>
<name>JBoss AS Quickstarts: Helloworld</name>
<description>JBoss AS Quickstarts: Helloworld</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>
    <!-- Explicitly declaring the source encoding eliminates the following 
        message: -->
    <!-- [WARNING] Using platform encoding (UTF-8 actually) to copy filtered 
        resources, i.e. build is platform dependent! -->
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

    <!-- JBoss dependency versions -->

    <version.org.jboss.as.plugins.maven.plugin>7.3.Final</version.org.jboss.as.plugins.maven.plugin>

    <!-- <version.org.jboss.spec.jboss.javaee.6.0>3.0.2.Final</version.org.jboss.spec.jboss.javaee.6.0>
Run Code Online (Sandbox Code Playgroud)

- > 3.0.2.Final-redhat-3

    <!-- other plugin versions -->
    <version.compiler.plugin>2.3.1</version.compiler.plugin>
    <version.war.plugin>2.1.1</version.war.plugin>

    <!-- maven-compiler-plugin -->
    <maven.compiler.target>1.6</maven.compiler.target>
    <maven.compiler.source>1.6</maven.compiler.source>
</properties>

<dependencyManagement>
    <dependencies>
        <!-- Define the version of JBoss' Java EE 6 APIs we want to use -->
        <!-- JBoss distributes a complete set of Java EE 6 APIs including
            a Bill of Materials (BOM). A BOM specifies the versions of a "stack" (or
            a collection) of artifacts. We use this here so that we always get the correct
            versions of artifacts. Here we use the jboss-javaee-6.0 stack (you can
            read this as the JBoss stack of the Java EE 6 APIs). You can actually
            use this stack with any version of JBoss AS that implements Java EE 6, not
            just JBoss AS 7! -->
        <dependency>
            <groupId>org.jboss.spec</groupId>
            <artifactId>jboss-javaee-6.0</artifactId>
            <version>${version.org.jboss.spec.jboss.javaee.6.0}</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

<dependencies>

    <!-- Import the CDI API, we use provided scope as the API is included in JBoss AS 7 -->
    <dependency>
        <groupId>javax.enterprise</groupId>
        <artifactId>cdi-api</artifactId>
        <scope>provided</scope>
    </dependency>

    <!-- Import the Common Annotations API (JSR-250), we use provided scope 
        as the API is included in JBoss AS 7 -->
    <dependency>
        <groupId>org.jboss.spec.javax.annotation</groupId>
        <artifactId>jboss-annotations-api_1.1_spec</artifactId>
        <scope>provided</scope>
    </dependency>

    <!-- Import the Servlet API, we use provided scope as the API is included in JBoss AS 7 -->
    <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>jboss-as-helloworld</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.org.jboss.as.plugins.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>
Run Code Online (Sandbox Code Playgroud)

gva*_*nto 5

好的,这是修正它的原因:

在pom.xml中注释掉这一行:(我认为这是一种变量,可以自动插入/替换为eclipse/something,结果不是不是):

<!--                 <version>${version.org.jboss.spec.jboss.javaee.6.0}</version> -->
Run Code Online (Sandbox Code Playgroud)

用...来代替:

<version>3.0.2.Final</version>
Run Code Online (Sandbox Code Playgroud)

它现在可以构建,我可以很好地部署它,感谢Nishant的帮助!


jam*_*han 5

如果您从github存储库克隆快速入门,例如

git clone --recursive git://github.com/jboss-jdf/jboss-as-quickstart.git --branch jdf-2.1.9.Final
Run Code Online (Sandbox Code Playgroud)

见:http://www.jboss.org/jdf/quickstarts/get-started/

然后你会在根目录中找到一个maven settings.xml文件(./jboss-as-quickstart/settings.xml)

对于每个示例,使用该设置文件运行maven:

cd jboss-as-quickstart
cd helloworld
mvn -s ..\settings.xml compile
Run Code Online (Sandbox Code Playgroud)

请参阅:http://www.jboss.org/jdf/quickstarts/jboss-as-quickstart/#configure-maven


小智 3

您可能需要创建一个(有关更多详细信息,请参阅此页面):

settings.xml 文件可能存在于两个位置:

  • Maven 安装:$M2_HOME/conf/settings.xml
  • 用户的安装:${user.home}/.m2/settings.xml

但我觉得问题出在依赖项的版本字符串上。对版本进行硬编码并重试:

<dependency>
    <groupId>org.jboss.spec</groupId>
    <artifactId>jboss-javaee-6.0</artifactId>
    <version>3.0.2.Final</version>
    <type>pom</type>
    <scope>import</scope>
</dependency>
Run Code Online (Sandbox Code Playgroud)

取消注释以下行也可能有效:

<version.org.jboss.spec.jboss.javaee.6.0>3.0.2.Final
    </version.org.jboss.spec.jboss.javaee.6.0>
Run Code Online (Sandbox Code Playgroud)