How to deploy .war file to JBoss AS 7 server using Maven?

后端 未结 2 379
遇见更好的自我
遇见更好的自我 2021-02-04 20:11

I have \"pom.xml\" file which is connecting to maven and checking out the code and creating a war file. Now I have to deploy the created war file to JBoss Application Server 7.

相关标签:
2条回答
  • 2021-02-04 20:36

    First, use bin/add-user.sh to add management user.

    Then, store that into your settings.xml.

    <profiles>
    
        <profile>
            <id>myproject-prod<id>
            <activation><activeByDefault>true</activeByDefault></activation>
            <properties>
                <myproject.deploy.pass.prod>mySecretPassword</myproject.deploy.pass.prod>
            </properties>
        </profile>
    
    </profiles>
    

    Then, configure the 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>
    

    and then simply...

    mvn clean deploy;
    

    This is reduced from one JBoss project, may contain typos, but should work.

    0 讨论(0)
  • 2021-02-04 20:45
    • First, use bin/add-user.sh to add management user(admin/1234).

    • Second add to 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>
      

    • Three: edit JBoss_Home/standalone/configuration/standalone.xml change the Ip address to 0.0.0.0: enter image description here

    • Four, deploy using #clean install jboss-as:redeploy enter image description here

    0 讨论(0)
提交回复
热议问题