执行以下命令创建项目骨架:
mvn archetype:generate -DarchetypeGroupId=org.jboss.spec.archetypes -DarchetypeArtifactId=jboss-javaee6-webapp-ear-archetype -DarchetypeVersion=7.1.1.Final -DgroupId={你的groupId} -DartifactId={你的artifactId} -Dversion=1.0-SNAPSHOT
找到根目录下的 pom.xml 的 build 节点,添加以下内容:
<build> ... <plugins> ... <plugin> <groupId>org.wildfly.plugins</groupId> <artifactId>wildfly-maven-plugin</artifactId> <version>1.0.1.Final</version> </plugin> ... </plugins> ... </build>
添加 jsf-api:
<dependency> <groupId>org.jboss.spec.javax.faces</groupId> <artifactId>jboss-jsf-api_2.2_spec</artifactId> <version>2.2.0</version> </dependency>
然后切换到 ear 目录,找到 pom.xml 文件,添加以下内容:
<plugin> <groupId>org.wildfly.plugins</groupId> <artifactId>wildfly-maven-plugin</artifactId> </plugin
<defaultGoal>package</defaultGoal>
更新 tag namespace:
xmlns:ui="http://xmlns.jcp.org/jsf/facelets" xmlns:f="http://xmlns.jcp.org/jsf/core" xmlns:h="http://xmlns.jcp.org/jsf/html"
<faces-config xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-facesconfig_2_2.xsd" version="2.2"> </faces-config>
OK大功告成。如果要在此基础上进行开发,还需要修改 persistence.xml 和 *.ds.xml 文件。
部署方法:
mvn clean install cd ***-ear mvn wildfly:deploy