使用maven-jboss-plugin插件部署EJB
例子
1.创建项目,用命令行进入创建项目的目录,如:E:\test
mvn archetype:create -DgroupId=com.mycompany.app -DartifactId=my-webapp -DarchetypeArtifactId=maven-archetype-webapp
2.修改pom.xml
code:
<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>com.mycompany.app</groupId> <artifactId>my-webapp</artifactId> <packaging>war</packaging> <version>1.0-SNAPSHOT</version> <name>my-webapp Maven Webapp</name> <url>http://maven.apache.org</url> <dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>3.8.1</version> <scope>test</scope> </dependency> </dependencies> <build> <finalName>my-webapp</finalName> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-war-plugin</artifactId> <configuration> <archive> <addMavenDescriptor>false</addMavenDescriptor> </archive> </configuration> </plugin> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>jboss-maven-plugin</artifactId> <version>1.5.0</version> <configuration> <jbossHome>C:\Program Files\server\jboss-4.2.2.GA</jbossHome> <serverName>all</serverName> <fileName>target/my-webapp.war</fileName> </configuration> </plugin> </plugins> </build> </project>
//其中 <jbossHome> E:\zgh\jboss-eap-4.3.0.GA_CP08\jboss-as</jbossHome>
配置表示的jboss所在的目录
/**
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<archive>
<addMavenDescriptor>false</addMavenDescriptor>
</archive>
</configuration>
</plugin>
**/
这段表示该项目要打war包 这是配置maven打war包的配置
E:\zgh\jboss-eap-4.3.0.GA_CP08\jboss-as配置表示的jboss所在的目录,如:
E:\zgh\jboss-eap-4.3.0.GA_CP08\jboss-as
3.进入my-webapp目录,进入下一个步骤:
mvn clean install -Dmaven.test.skip=true
//将项目打包成war包
4.启动jboss服务
mvn jboss:start
5.部署war包
mvn jboss:hard-deploy
6.测试
启动jboss服务器,进入E:\zgh\jboss-eap-4.3.0.GA_CP08\jboss-as\bin目录,命令 run.bat -c all启动jboss服务器。
地址栏输入 http://localhost:8080/my-webapp/ 页面是个hello word!
至此,部署EJB成功。
参考网址:
http://demojava.iteye.com/blog/1083826
http://mojo.codehaus.org/jboss-maven-plugin/index.html#examplesdeploy-undeploy-examples.html