[英]How to deploy src/main/webapp folder (Maven) as an application in JBoss7?
I want to deploy my src/main/webapp folder from Maven project as an application in JBoss7. 我想从Maven项目中部署我的src / main / webapp文件夹作为JBoss7中的一个应用程序。 What I'm trying to do is to: 我想做的是:
mvn prepare-package war:inplace
for full deployment 做mvn prepare-package war:inplace
进行全面部署 This is of course for development only. 这当然只是为了开发。 I want to have similar workflow as with Maven Jetty plugin but for JEE6 app. 我希望有与Maven Jetty插件类似的工作流程,但是对于JEE6应用程序。
Deployment scanner is looking for *.war directories. 部署扫描程序正在寻找* .war目录。
My current solutions: 我目前的解决方案
war:exploded
to copy resources to war dir. 将我的目标文件夹添加到deployment-scanner并添加war:exploded
以将资源复制到war dir。 Full redeployment needs creating .dodeploy file with antrun plugin and this is quite ugly. 完全重新部署需要使用antrun插件创建.dodeploy文件,这非常难看。 I still need to run maven after saving resources. 我仍然需要在保存资源后运行maven。 I don't want my resources to be copied anywhere. 我不希望我的资源被复制到任何地方。 There is nothing special in my pom.xml
: 我的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>com.pg</groupId>
<artifactId>jeesample</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>jeesample</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-web-api</artifactId>
<version>6.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.primefaces</groupId>
<artifactId>primefaces</artifactId>
<version>3.3.1</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.6.6</version>
</dependency>
</dependencies>
<build>
<finalName>jeesample.war</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>prime-repo</id>
<name>PrimeFaces Maven Repository</name>
<url>http://repository.primefaces.org</url>
<layout>default</layout>
</repository>
</repositories>
Try to use the maven-war-plugin . 尝试使用maven-war-plugin 。 Maven should add your depenendencies. Maven应该添加你的依赖项。 Note, however, that JBoss 7 has a new module dependency system, so if you want to use some internal modules provided by jboss you have to state them in your MANIFEST.MF file as in the example and mark them as provided in the pom.xml. 但是请注意,JBoss 7有一个新的模块依赖系统,所以如果你想使用jboss提供的一些内部模块,你必须在你的MANIFEST.MF文件中说明它们,如示例所示,并将它们标记为pom中提供的。 XML。 JBoss 7 reads the manifest and loads the modules upon deploy JBoss 7读取清单并在部署时加载模块
Here is an example that works for me: 这是一个适合我的例子:
...
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.1.1</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
<archive>
<manifestEntries>
<Built-By>Dev Team</Built-By>
<Dependencies>javaee.api, javax.faces.api, javax.xml.rpc.api,
org.joda.time, org.hibernate, org.hibernate.validator,
org.dom4j, org.picketlink</Dependencies>
</manifestEntries>
</archive>
</configuration>
</plugin>
...
With this config the correct war is created (mvn war:war). 使用此配置可以创建正确的战争(mvn war:war)。 Also when I right click on the project in eclipse and choose > 'Run on Server' the war is deployed correctly. 此外,当我在eclipse中右键单击项目并选择>'Run on Server'时,正确部署了war。 Resources such as xhtml, etc are automatically redeployed on save and the changes are visible upon refresh. 诸如xhtml等资源会在保存时自动重新部署,并且在刷新时可以看到更改。 I also have the m2eclipse plugin installed 我也安装了m2eclipse插件
if you can switch to play framework, this will increase productivity very much. 如果你可以切换到播放框架,这将非常提高生产力。 reall... it's like ruby on rails. reall ...就像铁轨上的红宝石一样。
Also if you are using maven, probably this can help to automatically deploy EAR during install phase 此外,如果您使用maven,这可能有助于在安装阶段自动部署EAR
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.4</version>
<configuration>
<artifactItems>
<artifactItem>
<groupId>${project.groupId}</groupId>
<artifactId>${project.artifactId}</artifactId>
<version>${project.version}</version>
<type>ear</type>
<overWrite>true</overWrite>
<outputDirectory>${jboss-inst}/deploy</outputDirectory>
</artifactItem>
</artifactItems>
<skip>${skip.ear.auto.deployment}</skip>
</configuration>
<executions>
<execution>
<phase>install</phase>
<goals>
<goal>copy</goal>
</goals>
</execution>
</executions>
</plugin>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.