2013-06-28 118 views
5

我有一个“pom.xml”文件,它连接到maven并检出代码并创建一个war文件。现在我必须将创建的war文件部署到JBoss Application Server 7.下面是我的pom.xml如何使用Maven将.war文件部署到JBoss AS 7服务器?

<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.deploy</groupId> 
    <artifactId>deploy-app</artifactId> 
    <packaging>war</packaging> 
    <version>0.0.1-SNAPSHOT</version> 
    <name>deploy-app Maven Webapp</name> 
    <url>http://maven.apache.org</url> 
    <scm> 
     <connection>scm:svn:http://d-113017553/svn/PRONTO/trunk/dev</connection> 
     <developerConnection>scm:svn:http://d-113017553/svn/PRONTO/trunk   /dev</developerConnection> 
     <url>http://d-113017553/svn/PRONTO/trunk/dev</url> 
    </scm> 
    <dependencies> 
     <dependency> 
     <groupId>junit</groupId> 
     <artifactId>junit</artifactId> 
     <version>3.8.1</version> 
     <scope>test</scope> 
     </dependency> 
    </dependencies> 
    <build> 
     <finalName>deploy-app</finalName> 
     <plugins> 
     <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-scm-plugin</artifactId> 
      <version>1.8.1</version> 
      <configuration> 
       <connectionType>connection</connectionType> 
       <username>keerthana</username> 
       <password>keerthana</password> 
       <checkoutDirectory>${project.basedir}/co/src</checkoutDirectory> 
       <workingDirectory>${project.basedir}/co/src</workingDirectory> 
      </configuration> 
     </plugin> 
     <plugin> 
      <artifactId>maven-release-plugin</artifactId> 
      <version>2.2.2</version> 
      <configuration> 
       <releaseProfiles>release</releaseProfiles> 
       <goals>scm:checkout</goals> 
      </configuration> 
     </plugin> 
     <plugin> 
      <groupId>org.jboss.as.plugins</groupId> 
      <artifactId>jboss-as-maven-plugin</artifactId> 
      <version>7.3.Final</version> 
      <configuration> 
       <jboss_Home>D:\Workspace\deploy-app\target</jboss_Home> 
       <serverName>default</serverName> 
       <fileName>target/deploy-app.war</fileName> 
      </configuration> 
     </plugin> 
     </plugins> 
    </build> 
</project> 

请给我将我的战争文件部署到Jboss服务器的步骤。

+1

一旦检查下面的链接可能对你有用http://stackoverflow.com/questions/13376011/war-file-deployment-in-jboss-4-2-server-with-maven-repositories –

+0

我得到以下错误, – Keerthana

+0

无法执行目标org.jboss.as.plugins:jboss-as-maven-plugin:7.3.Final:在项目deploy-app上部署(默认):无法对D:\执行目标部署。工作区\部署,应用程序\目标\部署,app.war。原因:错误无法执行操作'ERROR]“address”=> [], [ERROR]“operation”=>“读取属性”, [ERROR]“name”=>“launch-type” [错误]}'。 java.net.ConnectException:JBAS012144:无法连接到remote:// D-0190918:8080。连接超时 请帮帮我 – Keerthana

回答

7

首先,使用bin/add-user.sh添加管理用户。

然后,将其存储到您的settings.xml中。然后,配置pom.xml

<properties> 
    <jboss-as.deploy.hostname>localhost</jboss-as.deploy.hostname> <!-- Where to deploy. --> 
    <jboss-as.deploy.user>admin</jboss-as.deploy.user> 
    <jboss-as.deploy.pass>${myproject.deploy.pass.prod}</jboss-as.deploy.pass> 
    <plugin.war.warName>${project.build.finalName}</plugin.war.warName> 
</properties> 

...

<plugins> 
     <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-war-plugin</artifactId> 
      <version>2.3</version> 
      <configuration> 
       <filteringDeploymentDescriptors>true</filteringDeploymentDescriptors> 
       <warName>${plugin.war.warName}</warName> 
      </configuration> 
     </plugin>    

     <!-- JBoss AS plugin to deploy the war. --> 
     <plugin> 
      <groupId>org.jboss.as.plugins</groupId> 
      <artifactId>jboss-as-maven-plugin</artifactId> 
      <version>7.4.Final</version> 
      <configuration> 
       <force>true</force> 
       <hostname>${jboss-as.deploy.hostname}</hostname> 
       <username>${jboss-as.deploy.user}</username> 
       <password>${jboss-as.deploy.pass.prod}</password> 
       <fileNames> 
        <fileName>target/${plugin.war.warName}.war</fileName> 
       </fileNames> 
      </configuration> 
     </plugin> 
    </plugins> 

,然后简单地...

mvn clean deploy; 

这是从一个JBoss的项目减少,可能包含错别字,但应该工作。

+0

感谢您的回复。我会尝试上述步骤。 – Keerthana

+0

你能告诉我我必须在bin/add-user.sh中添加什么吗?我对maven很陌生,在执行上述步骤时出现错误。 – Keerthana

+0

如果您正在部署到在本地机器上运行的服务器,则不需要添加用户。如果您正在部署到远程服务器,则只需添加用户。 –

0
  • 首先,使用bin/add-user.sh添加管理用户(admin/1234)。

  • 其次添加到pom.xml中:

    <build>  
    <plugins>  
        <plugin> 
         <groupId>org.jboss.as.plugins</groupId> 
         <artifactId>jboss-as-maven-plugin</artifactId> 
         <version>7.5.Final</version> 
         <configuration> 
          <hostname>localhost</hostname> 
          <port>9999</port> 
          <name>app_name.war</name> 
          <username>admin</username> 
          <password>1234</password> 
         </configuration> 
        </plugin> 
    </plugins> 
    

  • 三:编辑JBOSS_HOME /独立/配置/ standalone.xml更改IP地址为0.0.0.0: enter image description here

  • 四,部署使用#clean install jboss-as:重新部署 enter image description here

+0

在服务器或用户中添加用户我们要部署的远程盒子?你能告诉我我正面临着一个问题... – Vikram

0

以前的解决方案没有工作。

我得到了一个错误:

[ERROR] Failed to execute goal org.jboss.as.plugins:jboss-as-maven-plugin:7.5.Final:deploy (default-cli) on project bitcoincalculator-front: Could not execute goal deploy on /home/frederik/git/bitcoincalculator/app/target/app.war. Reason: I/O Error could not execute operation '{ 
[ERROR] "operation" => "read-attribute", 
[ERROR] "address" => [], 
[ERROR] "name" => "launch-type" 
[ERROR] }': java.net.ConnectException: JBAS012144: Could not connect to remote://localhost:9999. The connection timed out 

必须查看解决方案之前发布。这不是专业

相关问题