forked from spring-projects/spring-boot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathusage.apt.vm
138 lines (115 loc) · 4.16 KB
/
usage.apt.vm
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
-----
Usage
-----
Stephane Nicoll
-----
2014-05-06
-----
Usage
The plugin offers a goal for repackaging an application as an executable JAR/WAR as well as a goal
for running the application.
* Repackaging an application
In order to repackage your application, you simply need to add a reference to the
plugin in your <<<pom.xml>>>:
---
<build>
...
<plugins>
...
<plugin>
<groupId>${project.groupId}</groupId>
<artifactId>${project.artifactId}</artifactId>
<version>${project.version}</version>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
...
</plugins>
...
</build>
---
The example above repackages a jar or war that is built during the package phase of the Maven lifecycle,
including any <<<provided>>> dependencies that are defined in the project. If some of these dependencies
need to be excluded, you can use one of the exclude options,
see {{{./examples/exclude-dependency.html}Exclude a dependency}} for more details.
The original (i.e. non exectuable) artifact is renamed to <<<.original>>> by default but it is also
possible to keep the original artifact using a custom classifier.
The plugin rewrites your manifest, and in particular it manages the <<Main-Class>> and <<Start-Class>>
entries, so if the defaults don't work you have to configure those there (not in the jar plugin). The
<<Main-Class>> in the manifest is actually controlled by the <<layout>> property of the boot plugin, e.g.
---
<build>
...
<plugins>
...
<plugin>
<groupId>${project.groupId}</groupId>
<artifactId>${project.artifactId}</artifactId>
<version>${project.version}</version>
<configuration>
<mainClass>${start-class}</mainClass>
<layout>ZIP</layout>
</configuration>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
...
</plugins>
...
</build>
---
The layout property defaults to a guess based on the archive type (jar or war). For the
<<<PropertiesLauncher>>> the layout is <<<ZIP>>> (even though the output might be a jar file).
For more detailed examples of how to configure this goal see:
* {{{./examples/repackage-classifier.html}Custom repackage classifier}}
* {{{./examples/exclude-dependency.html}Exclude a dependency}}
[]
* Running the application
The plugin includes a run goal which can be used to launch your application from the command
line:
---
mvn spring-boot:run
---
The application is forked in a separate process. If you need to specify some JVM arguments
(i.e. for debugging purposes), you can use the <<<jvmArguments>>> parameter, see
{{{./examples/run-debug.html}Debug the application}} for more details.
By default, any <<src/main/resources>> folder will be added to the application classpath
when you run the application and any duplicate found in <<target/classes>> will be
removed. This allows hot refreshing of resources which can be very useful when developing
web applications. For example, you can work on HTML, CSS or JavaScipt files and see your
changes immediately without recompiling your application. It is also a helpful way of
allowing your front end developers to work without needing to download and install a Java IDE.
Of course, if your resources are using tokens that are filtered by Maven, you may want
to disable that feature as follows:
---
<build>
...
<plugins>
...
<plugin>
<groupId>${project.groupId}</groupId>
<artifactId>${project.artifactId}</artifactId>
<version>${project.version}</version>
<configuration>
<addResources>false</addResources>
</configuration>
</plugin>
...
</plugins>
...
</build>
---
In order to be consistent with the <<<repackage>>> goal, the <<<run>>> goal builds the classpath
in such a way that any dependency that is excluded in the plugin's configuration gets excluded
from the classpath as well. See {{{./examples/exclude-dependency.html}Exclude a dependency}} for
more details.