maven打包web项目

首先在pom.xml文件中指定war的打包方式,war

然后在pom文件的plugins节点下面增加如下内容即可mvn package时同时生成war, jar包。为了 mvn package install, mvn package deploy能够同时部署jar包,我们增加了后面2节点的配置:

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

<plugin>

  <groupId>org.apache.maven.pluginsgroupId>

  <artifactId>maven-jar-pluginartifactId>

  <executions>

  <execution>

    <id>make-a-jarid>

    <phase>compilephase>

    <goals>

      <goal>jargoal>

    goals>

  execution>

  executions>

plugin>

<plugin>

<groupId>org.apache.maven.pluginsgroupId>

<artifactId>maven-install-pluginartifactId>

<executions>

<execution>

<phase>installphase>

<goals>

<goal>install-filegoal>

goals>

<configuration>

<packaging>jarpackaging>

<artifactId>${project.artifactId}artifactId>

<groupId>${project.groupId}groupId>

<version>${project.version}version>

<file>

${project.build.directory}/${project.artifactId}-${project.version}.jar

file>

configuration>

execution>

executions>

plugin>

<plugin>

 <groupId>org.apache.maven.pluginsgroupId>

 <artifactId>maven-deploy-pluginartifactId>

 <executions>

 <execution>

 <phase>deployphase>

 <goals>

  <goal>deploy-filegoal>

 goals>

 <configuration>

 <packaging>jarpackaging>

 <generatePom>truegeneratePom>

 <url>${project.distributionManagement.repository.url}url>

 <artifactId>${project.artifactId}artifactId>

 <groupId>${project.groupId}groupId>

 <version>${project.version}version>

 <file>${project.build.directory}/${project.artifactId}.jarfile>

 configuration>

 execution>

 executions>

plugin>

最后,发布到远程仓库 插件可以按自己需要屏蔽。

你可能感兴趣的:(maven)