Jboss eap 6+和maven仓库运行时间参考位置 [英] Jboss eap 6+ and maven repository run time reference location

查看:238
本文介绍了Jboss eap 6+和maven仓库运行时间参考位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我非常新的Jboss eap 6+和maven。


我已经使用Eclipse的Jboss工具插件创建了一个示例项目,并通过eclipse部署。


我没有单独安装maven,它来自上面的插件我猜。


根据我的知识maven下载在.pom文件中提到的所有必需的JAR文件到本地存储库。在我的情况下.m2\repository\位置。


但是我不明白Jboss在生产服务器中单独运行时如何引用这个位置。我们没有任何eclipse或jboss工具。


我在已部署的项目中检查了.pom文件,但我没有注意到任何位置引用。
从技术上讲,我不明白这是如何工作的。如果有人可以进一步解释,这是非常有帮助的。


我的问题是,如果我将项目上传到不同服务器中的不同Jboss,它将自动下载所有需要的JAR。 pom文件部署时?如果是什么位置?如何更改该位置?


设置生产环境(maven仓库)时,必须遵循的具体步骤是什么?


只需将我的Jboss与部署的项目一起复制到生产环境中,那么我可以期望Jboss和项目.pom文件处理JAR和依赖关系?


或者我需要安装和配置maven和repository在生产环境中?
我的理解可能不正确。非常感谢您能帮助我。



谢谢



请在已部署的项目中找到.pom文件。



 < project xmlns =http://maven.apache.org/POM/4.0.0xmlns:xsi =http://www.w3.org/2001/XMLSchema-instancexsi: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.jboss.tools.example.html5< / groupId>
< artifactId> jboss-as-kitchensink-html5-mobile< / artifactId>
< version> 0.0.1-SNAPSHOT< / version>
< packaging> war< / packaging>

< name> jboss-as-kitchensink-html5-mobile< / name>
< description>用于JBoss的Java EE 6 HTML5移动Web应用程序< / description>

< url> http://jboss.org/aerogear< / url>

< properties>
<! - 明确声明源编码消除了以下消息: - >
<! - [WARNING]使用平台编码(实际上是UTF-8)来复制过滤的资源,即构建是平台依赖的! - >
< project.build.sourceEncoding> UTF-8< /project.build.sourceEncoding>

<! - 您可以引用pom.xml中的属性或过滤的资源(如果使用Maven 2.1,则必须启用第三方插件) - >

<! - JBoss依赖版本 - >

< version.jboss.maven.plugin> 7.4.Final< /version.jboss.maven.plugin>
<! - 或者,注释掉上述行,并取消评论以下
行使用版本7.2.0.Final-redhat-8,这是一个已发布认证的
使用JBoss EAP 6.它需要您可以访问JBoss EAP 6
maven存储库。 - >
<! - < version.jboss.as> 7.2.0.Final-redhat-8< /version.jboss.as& - >

<! - 定义要导入的JBoss BOM的版本,以指定测试堆栈。 - >
< version.jboss.bom> 1.0.7.Final< /version.jboss.bom>
<! - 或者,注释掉上面的一行,并取消评论以下行
使用版本1.0.4.Final-redhat-wfk-2,这是一个经过$ b认证的发行版$ b使用JBoss EAP 6.它需要您可以访问JBoss EAP 6
maven存储库。 - >
<! - < version.jboss.bom> 1.0.4.Final-redhat-wfk-2< /version.jboss.bom>> - >


<! - 其他依赖关系版本 - >
< version.org.eclipse.m2e> 1.0.0< /version.org.eclipse.m2e>
< version.ro.isdc.wro4j> 1.4.4< /version.ro.isdc.wro4j>

<! - 其他插件版本 - >
< version.surefire.plugin> 2.10< /version.surefire.plugin>
< version.war.plugin> 2.2< /version.war.plugin>

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

< licenses>
< license>
< name> Apache许可证版本2.0< / name>
< distribution> repo< / distribution>
< url> http://www.apache.org/licenses/LICENSE-2.0.html< / url>
< / license>
< / licenses>

< dependencyManagement>
<依赖关系>
<! - JBoss分发一套完整的Java EE 6 API,包括
物料清单(BOM)。 BOM指定工件的堆栈(或
一个集合)的版本。我们在这里使用这个,以便我们总是得到正确的
版本的工件。这里我们使用jboss-javaee-6.0-with-tools stack
(您可以将其作为Java EE 6 API的JBoss堆栈读取,并为您的项目添加了一些额外的
工具,例如Arquillian for测试)和jboss-javaee-6.0-with-hibernate
堆栈,您可以将其作为Java EE 6 API的JBoss堆栈读取,并从Hibernate系列项目中添加

<依赖关系>
< groupId> org.jboss.bom< / groupId>
< artifactId> jboss-javaee-6.0-with-tools< / artifactId>
< version> $ {version.jboss.bom}< / version>
< type> pom< / type>
< scope> import< / scope>
< / 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>

<依赖关系>
<! - 首先声明我们依赖的和需要编译的API。所有这些都由JBoss提供 - >

<! - 导入CDI API,我们使用提供的范围,因为API包含在JBoss中 - >
<依赖关系>
< groupId> javax.enterprise< / groupId>
< artifactId> cdi-api< / artifactId>
< scope>已提供< / scope>
< / dependency>

<! - 导入公共注释API(JSR-250),我们使用提供的范围作为API包含在JBoss中 - >
<依赖关系>
< groupId> org.jboss.spec.javax.annotation< / groupId>
< artifactId> jboss-annotations-api_1.1_spec< / artifactId>
< scope>已提供< / scope>
< / dependency>

<! - 导入JAX-RS API,我们使用提供的范围作为API包含在JBoss - >
<依赖关系>
< groupId> org.jboss.spec.javax.ws.rs< / groupId>
< artifactId> jboss-jaxrs-api_1.1_spec< / artifactId>
< scope>已提供< / scope>
< / dependency>

<! - 导入JPA API,我们使用提供的范围作为API包含在JBoss - >
<依赖关系>
< groupId> org.hibernate.javax.persistence< / groupId>
< artifactId> hibernate-jpa-2.0-api< / artifactId>
< scope>已提供< / scope>
< / dependency>

<! - 导入EJB API,我们使用提供的范围作为API包含在JBoss - >
<依赖关系>
< groupId> org.jboss.spec.javax.ejb< / groupId>
< artifactId> jboss-ejb-api_3.1_spec< / artifactId>
< scope>已提供< / scope>
< / dependency>

<! - 导入Servlet API,我们使用提供的范围作为API包含在JBoss AS 7 - >
<依赖关系>
< groupId> org.jboss.spec.javax.servlet< / groupId>
< artifactId> jboss-servlet-api_3.0_spec< / artifactId>
< scope>已提供< / scope>
< / dependency>

<! - JSR-303(Bean验证)实现 - >
<! - 提供便携式约束,如@Email - >
<! - Hibernate验证器在JBoss中发布 - >
<依赖关系>
< groupId> org.hibernate< / groupId>
< artifactId> hibernate-validator< / artifactId>
< scope>已提供< / scope>
<排除>
< exclude>
< groupId> org.slf4j< / groupId>
< artifactId> slf4j-api< / artifactId>
< / exclusion>
< / exclusions>
< / dependency>

<! - 现在我们声明任何需要的工具 - >

<! - 用于为类型安全标准查询生成JPA 2.0元模型类的注释处理器 - >
<依赖关系>
< groupId> org.hibernate< / groupId>
< artifactId> hibernate-jpamodelgen< / artifactId>
< scope>已提供< / scope>
< / dependency>

<! - 需要运行测试(您也可以使用TestNG) - >
<依赖关系>
< groupId> junit< / groupId>
< artifactId> junit< / artifactId>
< scope> test< / scope>
< / dependency>

<! - 可选,但强烈推荐 - >
<! - Arquillian允许您从JUnit / TestNG - >测试企业代码,如EJB和事务(JTA)JPA。
<依赖关系>
< groupId> org.jboss.arquillian.junit< / groupId>
< artifactId> arquillian-junit-container< / artifactId>
< scope> test< / scope>
< / dependency>

<依赖关系>
< groupId> org.jboss.arquillian.protocol< / groupId>
< artifactId> arquillian-protocol-servlet< / artifactId>
< scope> test< / scope>
< / dependency>

< / dependencies>

< build>
<! - Maven将附加版本到finalName(这是给予生成的战争的名称,因此上下文
root) - >
< finalName> $ {project.artifactId}< / finalName>
< plugins>
< plugin>
< artifactId> maven-war-plugin< / artifactId>
< version> $ {version.war.plugin}< / version>
< configuration>
<! - Java EE 6不需要web.xml,Maven需要赶上! - >
< failOnMissingWebXml> false< / failOnMissingWebXml>
< / configuration>
< / plugin>
<! - JBoss AS插件将您的战争部署到本地JBoss AS容器 - >
<! - 要使用,请运行:mvn package jboss-as:deploy - >
< plugin>
< groupId> org.jboss.as.plugins< / groupId>
< artifactId> jboss-as-maven-plugin< / artifactId>
< version> $ {version.jboss.maven.plugin}< / version>
< / plugin>

< / plugins>
< / build>

<个人资料>
<个人资料>
<! - 默认配置文件将跳过所有测试,尽管您可以调整它来运行基于自定义模式的单元测试 - >
<! - 提供分离配置文件用于运行所有测试,包括在指定容器中执行的Arquillian测试 - >
< id> default< / id>
< activate>
< activeByDefault> true< / activeByDefault>
< / activation>
< build>
< plugins>
< plugin>
< artifactId> maven-surefire-plugin< / artifactId>
< version> $ {version.surefire.plugin}< / version>
< configuration>
< skip> true< / skip>
< / configuration>
< / plugin>
< / plugins>
< / build>
< / profile>
<个人资料>
<! - 当内置OpenShift时,调用mvn时将使用'openshift'配置文件。 - >
<! - 使用此配置文件用于您的应用程序需要的任何OpenShift特定定制。 - >
<! - 默认情况下,将生成的归档放入'deployments'文件夹。 - >
<! - http://maven.apache.org/guides/mini/guide-building-for-different-environments.html - >
< id> openshift< / id>
< build>
< plugins>
< plugin>
< artifactId> maven-war-plugin< / artifactId>
< version> $ {version.war.plugin}< / version>
< configuration>
< outputDirectory>部署< / outputDirectory>
< warName> ROOT< / warName>
< / configuration>
< / plugin>
< / plugins>
< / build>
< / profile>
<个人资料>
<! - 使用此配置文件使用wro4j插件进行验证,级联和 - >
<! - 构建期间JavaScript和CSS文件的缩小 - >
< id> minify< / id>
< activate>
< activeByDefault> false< / activeByDefault>
< / activation>

< build>
< pluginManagement>
< plugins>
<! - 此插件的配置仅用于存储Eclipse m2e设置。它对Maven构建本身没有影响.-->
< plugin>
< groupId> org.eclipse.m2e< / groupId>
< artifactId>生命周期映射< / artifactId>
< version> $ {version.org.eclipse.m2e}< / version>
< configuration>
< lifecycleMappingMetadata>
< pluginExecutions>
< pluginExecution>
< pluginExecutionFilter>
< groupId> ro.isdc.wro4j< / groupId>
< artifactId>
wro4j-maven-plugin
< / artifactId>
< version> $ {version.ro.isdc.wro4j}< / version>
< goals>
< goal>运行< / goal>
< / goals>
< / pluginExecutionFilter>
< action>
< ignore>< / ignore>
< / action>
< / pluginExecution>
< / pluginExecutions>
< / lifecycleMappingMetadata>
< / configuration>
< / plugin>
< / plugins>
< / pluginManagement>
< plugins>
< plugin>
< groupId> ro.isdc.wro4j< / groupId>
< artifactId> wro4j-maven-plugin< / artifactId>
< version> $ {version.ro.isdc.wro4j}< / version>
<执行>
< execution>
< phase> compile< / phase>
< goals>
< goal>运行< / goal>
< / goals>
< / execution>
< / executions>
< configuration>
< targetGroups> app.min,m.screen.min,d.screen.min< / targetGroups>
< cssDestinationFolder> $ {project.build.directory} / $ {project.build.finalName} / css /< / cssDestinationFolder>
< jsDestinationFolder> $ {project.build.directory} / $ {project.build.finalName} / js /< / jsDestinationFolder>
< wroManagerFactory> ro.isdc.wro.maven.plugin.manager.factory.ConfigurableWroManagerFactory< / wroManagerFactory>
< / configuration>
< / plugin>
< plugin>
< artifactId> maven-surefire-plugin< / artifactId>
< version> $ {version.surefire.plugin}< / version>
<配置>
< skip> true< / skip>
< / configuration>
< / plugin>
< / plugins>
< / build>
< / profile>
<个人资料>
<! - 一个可选的Arquillian测试配置文件,用于在JBoss AS实例中执行测试 - >
<! - 此配置文件将启动一个新的JBoss AS实例,并执行测试,在完成时将其关闭 - >
<! - 运行:mvn clean test -Parq-jbossas-managed - >
< id> arq-jbossas-managed< / id>
<依赖关系>
<依赖关系>
< groupId> org.jboss.as< / groupId>
< artifactId> jboss-as-arquillian-container-managed< / artifactId>
< scope> test< / scope>
< / dependency>
< /依赖关系>
< / profile>

<个人资料>
<! - 在远程JBoss AS实例中执行测试的可选的Arquillian测试配置文件。
<! - 运行:mvn clean test -Parq-jbossas-remote - >
< id> arq-jbossas-remote< / id>
<依赖关系>
<依赖关系>
< groupId> org.jboss.as< / groupId>
< artifactId> jboss-as-arquillian-container-remote< / artifactId>
< scope> test< / scope>
< / dependency>
< / dependencies>
< / profile>

<个人资料>
< id> aerogearci-jbossas-managed-7< / id>
<依赖关系>
<依赖关系>
< groupId> org.jboss.as< / groupId>
< artifactId> jboss-as-arquillian-container-managed< / artifactId>
< scope> test< / scope>
< / dependency>
< / dependencies>
< build>
< plugins>
< plugin>
< groupId> org.apache.maven.plugins< / groupId>
< artifactId> maven-surefire-plugin< / artifactId>
< version> $ {version.surefire.plugin}< / version>
< configuration>
< systemProperties>
< arquillian.launch> jbossci< /arquillian.launch>
< arquillian.jboss_home> $ {project.build.directory} / jboss-as - $ {version.jboss.as} /
< /arquillian.jboss_home>
< / systemProperties>
< includes>
< include> ** / *。java< / include>
< / includes>
< / configuration>
< / plugin>
< plugin>
< groupId> org.apache.maven.plugins< / groupId>
< artifactId> maven-dependency-plugin< / artifactId>
<执行>
< execution>
< id> unpack-as7< / id>
< phase> process-test-classes< / phase>
< goals>
< goal> unpack< / goal>
< / goals>
< configuration>
< artifactItems>
< artifactItem>
< groupId> org.jboss.as< / groupId>
< artifactId> jboss-as-dist< / artifactId>
< version> $ {version.jboss.as}< / version>
< outputDirectory> $ {project.build.directory}< / outputDirectory>
< type> zip< / type>
< overWrite> false< / overWrite>
< / artifactItem>
< / artifactItems>
< / configuration>
< / execution>
< / executions>
< / plugin>
< / plugins>
< / build>
< / profile>
< / profiles>

< / project>


解决方案

JBoss不下载或尝试找到任何您的应用程序在您的应用程序之外声明的依赖关系或其外部的模块或lib。



这是一个10000英尺的视图,了解maven如何打包WAR或EAR:




  • 首先,如果声明的依赖项已经在您的本地存储库中,那么它将会在每个从maven中央存储库声明的依赖关系,那么如果不存在,它会尝试从您在pom.xml中和您的settings.xml

  • 中声明的任何活动存储库下载,随时下载一个依赖关系,它解析其pom.xml,并使用maven下载依赖关系后的第一个和第二个步骤

  • 中描述的相同过程递归下载其依赖关系,它使用javac来编译项目和放置每个依赖关系被声明为编译依赖关系到目标目录的某个位置,所以当时它打包您的项目,编译依赖关系将在您的包中。请注意,如果您没有声明依赖关系的类型,则将其默认为编译依赖关系

  • 不会将声明为运行时或提供的依赖项打包在应用程序中,并且必须存在在jboss模块或jboss lib或您的应用程序将无法正确部署。



当然,这个10000英尺的maven视图软件包WAR或EAR不详细描述软件包构建生命周期的17个阶段中的任何一个。对构建生命周期的一个很好的参考是 http:// maven。 apache.org/guides/introduction/introduction-to-the-lifecycle.html ,以及对依赖机制的良好介绍是在 http://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html http://maven.apache.org/guides/introduction/introduction-to- optional-and-excludes-dependencies.html


I'm pretty new to Jboss eap 6+ and maven.

I have created a sample project using Jboss tool plug-in of eclipse and deployed via eclipse.

I didn't install maven separately, it came with above plug-in I guess.

As per my knowledge maven download all required JAR files that mentioned in .pom file in to local repository. In my case .m2\repository\ location.

But I don't understand how Jboss refer this location when it runs individually in a production server. There we don't have any eclipse or jboss tool.

I checked .pom file in deployed project and still I didn't notice any location reference. Technically I cannot understand how this works. It's really helpful if someone can explain bit further.

My question is, if I upload my project to a different Jboss in a different server, will it automatically down load all required JARs that mentioned in .pom file when deploying? If yes what is the location? How can I change that location?

What is the exact procedure I have to follow when setup a production kind of environment (subject to maven repository) ?

Just copy my Jboss along with deployed project to production environment, then can I expect Jboss and project .pom file take care of JARs and dependencies?

or do I need to install and configure maven and repository in production environment? What I understood may incorrect at all. It's really appreciate if you can help me on this.

Thanks

Please find .pom file in deployed project.

<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.jboss.tools.example.html5</groupId>
    <artifactId>jboss-as-kitchensink-html5-mobile</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>war</packaging>

    <name>jboss-as-kitchensink-html5-mobile</name>
    <description>A Java EE 6 HTML5 mobile web application for use with JBoss.</description>

    <url>http://jboss.org/aerogear</url>

    <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>

        <!-- You can reference property in pom.xml or filtered resources (must enable third-party plugin if using Maven < 2.1) -->

        <!-- JBoss dependency versions -->

        <version.jboss.maven.plugin>7.4.Final</version.jboss.maven.plugin>
        <!-- Alternatively, comment out the above line, and un-comment the 
            line below to use version 7.2.0.Final-redhat-8 which is a release certified 
            to work with JBoss EAP 6. It requires you have access to the JBoss EAP 6 
            maven repository. -->
        <!-- <version.jboss.as>7.2.0.Final-redhat-8</version.jboss.as> -->

        <!-- Define the version of the JBoss BOMs we want to import to specify tested stacks. -->
        <version.jboss.bom>1.0.7.Final</version.jboss.bom>
        <!-- Alternatively, comment out the above line, and un-comment the line
            below to use version 1.0.4.Final-redhat-wfk-2 which is a release certified to
            work with JBoss EAP 6. It requires you have access to the JBoss EAP 6
            maven repository. -->
        <!-- <version.jboss.bom>1.0.4.Final-redhat-wfk-2</version.jboss.bom>> -->


        <!-- Other dependency versions -->
        <version.org.eclipse.m2e>1.0.0</version.org.eclipse.m2e>
        <version.ro.isdc.wro4j>1.4.4</version.ro.isdc.wro4j>

        <!-- other plugin versions -->
        <version.surefire.plugin>2.10</version.surefire.plugin>
        <version.war.plugin>2.2</version.war.plugin>

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

    <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>

    <dependencyManagement>
        <dependencies>
            <!-- 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-with-tools stack 
                (you can read this as the JBoss stack of the Java EE 6 APIs, with some extras 
                tools for your project, such as Arquillian for testing) and the jboss-javaee-6.0-with-hibernate 
                stack you can read this as the JBoss stack of the Java EE 6 APIs, with extras 
                from the Hibernate family of projects) -->
            <dependency>
                <groupId>org.jboss.bom</groupId>
                <artifactId>jboss-javaee-6.0-with-tools</artifactId>
                <version>${version.jboss.bom}</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>
        <!-- First declare the APIs we depend on and need for compilation. All of them are provided by JBoss -->

        <!-- Import the CDI API, we use provided scope as the API is included in JBoss -->
        <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 -->
        <dependency>
            <groupId>org.jboss.spec.javax.annotation</groupId>
            <artifactId>jboss-annotations-api_1.1_spec</artifactId>
            <scope>provided</scope>
        </dependency>

        <!-- Import the JAX-RS API, we use provided scope as the API is included in JBoss -->
        <dependency>
            <groupId>org.jboss.spec.javax.ws.rs</groupId>
            <artifactId>jboss-jaxrs-api_1.1_spec</artifactId>
            <scope>provided</scope>
        </dependency>

        <!-- Import the JPA API, we use provided scope as the API is included in JBoss -->
        <dependency>
            <groupId>org.hibernate.javax.persistence</groupId>
            <artifactId>hibernate-jpa-2.0-api</artifactId>
            <scope>provided</scope>
        </dependency>

        <!-- Import the EJB API, we use provided scope as the API is included in JBoss -->
        <dependency>
            <groupId>org.jboss.spec.javax.ejb</groupId>
            <artifactId>jboss-ejb-api_3.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>

        <!-- JSR-303 (Bean Validation) Implementation -->
        <!-- Provides portable constraints such as @Email -->
        <!-- Hibernate Validator is shipped in JBoss -->
        <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>

        <!-- Now we declare any tools needed -->

        <!-- Annotation processor to generate the JPA 2.0 metamodel classes for typesafe criteria queries -->
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-jpamodelgen</artifactId>
            <scope>provided</scope>
        </dependency>

        <!-- Needed for running tests (you may also use TestNG) -->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <scope>test</scope>
        </dependency>

        <!-- Optional, but highly recommended -->
        <!-- Arquillian allows you to test enterprise code such as EJBs and Transactional(JTA) JPA from JUnit/TestNG -->
        <dependency>
            <groupId>org.jboss.arquillian.junit</groupId>
            <artifactId>arquillian-junit-container</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.jboss.arquillian.protocol</groupId>
            <artifactId>arquillian-protocol-servlet</artifactId>
            <scope>test</scope>
        </dependency>

    </dependencies>

    <build>
        <!-- Maven will append the version to the finalName (which is the name given to the generated war, and hence the context 
            root) -->
        <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>
            <!-- The JBoss AS plugin deploys your war to a local JBoss AS container -->
            <!-- To use, run: mvn package jboss-as:deploy -->
            <plugin>
                <groupId>org.jboss.as.plugins</groupId>
                <artifactId>jboss-as-maven-plugin</artifactId>
                <version>${version.jboss.maven.plugin}</version>
            </plugin>

        </plugins>
    </build>

    <profiles>
        <profile>
            <!-- The default profile skips all tests, though you can tune it to run just unit tests based on a custom pattern -->
            <!-- Seperate profiles are provided for running all tests, including Arquillian tests that execute in the specified container -->
            <id>default</id>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <artifactId>maven-surefire-plugin</artifactId>
                        <version>${version.surefire.plugin}</version>
                        <configuration>
                            <skip>true</skip>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <!-- When built in OpenShift the 'openshift' profile will be used when invoking mvn. -->
            <!-- Use this profile for any OpenShift specific customization your app will need. -->
            <!-- By default that is to put the resulting archive into the 'deployments' folder. -->
            <!-- http://maven.apache.org/guides/mini/guide-building-for-different-environments.html -->
            <id>openshift</id>
            <build>
                <plugins>
                    <plugin>
                        <artifactId>maven-war-plugin</artifactId>
                        <version>${version.war.plugin}</version>
                        <configuration>
                            <outputDirectory>deployments</outputDirectory>
                            <warName>ROOT</warName>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <!-- Use this profile to use the wro4j plugin for validation, concatenation and -->
            <!-- minification of JavaScript and CSS files during the build -->
            <id>minify</id>
            <activation>
                <activeByDefault>false</activeByDefault>
            </activation>

            <build>
                <pluginManagement>
                    <plugins>
                        <!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself.-->
                        <plugin>
                            <groupId>org.eclipse.m2e</groupId>
                            <artifactId>lifecycle-mapping</artifactId>
                            <version>${version.org.eclipse.m2e}</version>
                            <configuration>
                                <lifecycleMappingMetadata>
                                    <pluginExecutions>
                                        <pluginExecution>
                                            <pluginExecutionFilter>
                                                <groupId>ro.isdc.wro4j</groupId>
                                                <artifactId>
                                                    wro4j-maven-plugin
                                                </artifactId>
                                                <version>${version.ro.isdc.wro4j}</version>
                                                <goals>
                                                    <goal>run</goal>
                                                </goals>
                                            </pluginExecutionFilter>
                                            <action>
                                                <ignore></ignore>
                                            </action>
                                        </pluginExecution>
                                    </pluginExecutions>
                                </lifecycleMappingMetadata>
                            </configuration>
                        </plugin>
                    </plugins>
                </pluginManagement>
                <plugins>
                    <plugin>
                        <groupId>ro.isdc.wro4j</groupId>
                        <artifactId>wro4j-maven-plugin</artifactId>
                        <version>${version.ro.isdc.wro4j}</version>
                        <executions>
                            <execution>
                                <phase>compile</phase>
                                <goals>
                                    <goal>run</goal>
                                </goals>
                            </execution>
                        </executions>
                        <configuration>
                            <targetGroups>app.min,m.screen.min,d.screen.min</targetGroups>
                            <cssDestinationFolder>${project.build.directory}/${project.build.finalName}/css/</cssDestinationFolder>
                            <jsDestinationFolder>${project.build.directory}/${project.build.finalName}/js/</jsDestinationFolder>
                            <wroManagerFactory>ro.isdc.wro.maven.plugin.manager.factory.ConfigurableWroManagerFactory</wroManagerFactory>
                        </configuration>
                    </plugin>
                    <plugin>
                        <artifactId>maven-surefire-plugin</artifactId>
                        <version>${version.surefire.plugin}</version>
                        <configuration>
                            <skip>true</skip>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <!-- An optional Arquillian testing profile that executes tests in your JBoss AS instance -->
            <!-- This profile will start a new JBoss AS instance, and execute the test, shutting it down when done -->
            <!-- Run with: mvn clean test -Parq-jbossas-managed -->
            <id>arq-jbossas-managed</id>
            <dependencies>
                <dependency>
                    <groupId>org.jboss.as</groupId>
                    <artifactId>jboss-as-arquillian-container-managed</artifactId>
                    <scope>test</scope>
                </dependency>
            </dependencies>
        </profile>

        <profile>
            <!-- An optional Arquillian testing profile that executes tests in a remote JBoss AS instance -->
            <!-- Run with: mvn clean test -Parq-jbossas-remote -->
            <id>arq-jbossas-remote</id>
            <dependencies>
                <dependency>
                    <groupId>org.jboss.as</groupId>
                    <artifactId>jboss-as-arquillian-container-remote</artifactId>
                    <scope>test</scope>
                </dependency>
            </dependencies>
        </profile>

        <profile>
            <id>aerogearci-jbossas-managed-7</id>
            <dependencies>
                <dependency>
                    <groupId>org.jboss.as</groupId>
                    <artifactId>jboss-as-arquillian-container-managed</artifactId>
                    <scope>test</scope>
                </dependency>
            </dependencies>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-surefire-plugin</artifactId>
                        <version>${version.surefire.plugin}</version>
                        <configuration>
                            <systemProperties>
                                <arquillian.launch>jbossci</arquillian.launch>
                                <arquillian.jboss_home>${project.build.directory}/jboss-as-${version.jboss.as}/
                                </arquillian.jboss_home>
                            </systemProperties>
                            <includes>
                                <include>**/*.java</include>
                            </includes>
                        </configuration>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-dependency-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>unpack-as7</id>
                                <phase>process-test-classes</phase>
                                <goals>
                                    <goal>unpack</goal>
                                </goals>
                                <configuration>
                                    <artifactItems>
                                        <artifactItem>
                                            <groupId>org.jboss.as</groupId>
                                            <artifactId>jboss-as-dist</artifactId>
                                            <version>${version.jboss.as}</version>
                                            <outputDirectory>${project.build.directory}</outputDirectory>
                                            <type>zip</type>
                                            <overWrite>false</overWrite>
                                        </artifactItem>
                                    </artifactItems>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

</project>

解决方案

JBoss doesn't download or try to find any of your app declared dependencies outside your application or outside its modules or lib.

That's a 10000-foot view of how maven packages you WAR or EAR:

  • first it looks if a declared dependency is already at your local repository
  • second if it is not, it tries to download each declared dependency from the maven central repository, then if it is not there it tries to download from any active repository declared in your pom.xml and in your settings.xml
  • any time it downloads a dependency it parses its pom.xml and recursively downloads its dependencies using the same procedure described in the first and second steps
  • after maven downloads the dependencies, it uses javac to compile you project and puts every dependency declared as "compile dependency" somewhere into the target directory so when it packages your project, the compile dependencies will be inside your package. Note that if you don't declare the type of dependency you have it wil default to "compile dependency"
  • no dependencies declared as runtime or provided will be packaged within your application and must be present in a jboss module or the jboss lib or your application won't deploy correctly.

Of course this 10000-foot view of how maven packages a WAR or EAR doesn't describe any of the 17 phases of package build lifecycle in detail. A good reference to the build lifecycle is at http://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html, and good introduction to dependency mechanism is at http://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html and http://maven.apache.org/guides/introduction/introduction-to-optional-and-excludes-dependencies.html

这篇关于Jboss eap 6+和maven仓库运行时间参考位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆