Maven: How to rename the war file for the project?

前端 未结 4 627
广开言路
广开言路 2020-12-02 08:10

I have a project bird with following components in pom.xml

   com.myorg
    bird&l         


        
相关标签:
4条回答
  • 2020-12-02 08:19

    You can use the following in the web module that produces the war:

    <build>
      <finalName>bird</finalName>
     . . .
    </build>
    

    This leads to a file called bird.war to be created when goal "war:war" is used.

    0 讨论(0)
  • 2020-12-02 08:25

    Lookup pom.xml > project tag > build tag.

    I would like solution below.

    <artifactId>bird</artifactId>
    <name>bird</name>
    
    <build>
        ...
        <finalName>${project.artifactId}</finalName>
      OR
        <finalName>${project.name}</finalName>
        ...
    </build>
    

    Worked for me. ^^

    0 讨论(0)
  • 2020-12-02 08:26

    You need to configure the war plugin:

    <project>
      ...
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-war-plugin</artifactId>
            <version>2.3</version>
            <configuration>
              <warName>bird.war</warName>
            </configuration>
          </plugin>
        </plugins>
      </build>
      ...
    </project>
    

    More info here

    0 讨论(0)
  • 2020-12-02 08:33

    You can follow the below step to modify the .war file name if you are using maven project.

    Open pom.xml file of your maven project and go to the tag <build></build>,

    1. In that give your desired name between this tag : <finalName></finalName>.

      ex. : <finalName>krutik</finalName>

      After deploying this .war you will be able to access url with:
      http://localhost:8080/krutik/

    2. If you want to access the url with slash '/' then you will have to specify then name as below:

      e.x. : <finalName>krutik#maheta</finalName>

      After deploying this .war you will be able to access url with:
      http://localhost:8080/krutik/maheta

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