Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
6565ff61
Commit
6565ff61
authored
Sep 19, 2016
by
Andy Wilkinson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Clarify documentation on using a Spring Boot app as a dependency
Closes gh-6812
parent
155cfb18
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
14 deletions
+21
-14
build-tool-plugins.adoc
spring-boot-docs/src/main/asciidoc/build-tool-plugins.adoc
+3
-3
howto.adoc
spring-boot-docs/src/main/asciidoc/howto.adoc
+18
-11
No files found.
spring-boot-docs/src/main/asciidoc/build-tool-plugins.adoc
View file @
6565ff61
...
...
@@ -373,10 +373,10 @@ want the other Boot features but not this one)
|`
classifier
`
|
A
file
name
segment
(
before
the
extension
)
to
add
to
the
archive
,
so
that
the
original
is
preserved
in
its
original
location
.
Defaults
to
null
in
which
case
the
archive
is
preserved
in
its
original
location
.
Defaults
to
`
null
`
in
which
case
the
archive
is
repackaged
in
place
.
The
default
is
convenient
for
many
purposes
,
but
if
you
want
to
use
the
original
jar
as
a
dependency
in
another
project
,
it
's best to use an extension to
define
the executable archive.
the
original
jar
as
a
dependency
in
another
project
you
must
use
a
classifier
to
define
the
executable
archive
.
|`
withJarTask
`
|
The
name
or
value
of
the
`
Jar
`
task
(
defaults
to
all
tasks
of
type
`
Jar
`)
which
is
used
...
...
spring-boot-docs/src/main/asciidoc/howto.adoc
View file @
6565ff61
...
...
@@ -2643,14 +2643,24 @@ details.
[[howto-create-an-additional-executable-jar]]
=== Create an additional executable JAR
If you want to use your project as a library jar for other projects to depend on, and in
addition have an executable (e.g. demo) version of it, you will want to configure the
build in a slightly different way.
=== Use a Spring Boot application as a dependency
Like a war file, a Spring Boot application is not intended to be used as a dependency. If
your application contains classes that you want to share with other projects, the
recommended approach is to move that code into a separate module. The separate module can
then be depended upon by your application and other projects.
For Maven the normal JAR plugin and the Spring Boot plugin both have a '`classifier`'
configuration that you can add to create an additional JAR. Example (using the Spring
Boot Starter Parent to manage the plugin versions and other configuration defaults):
If you cannot rearrange your code as recommended above, Spring Boot's Maven and Gradle
plugins must be configured to produce a separate artifact that is suitable for use as a
dependency. The executable archive cannot be used as a dependency as the
<<appendix-executable-jar-format.adoc#executable-jar-jar-file-structure,exectuable jar
format>> packages application classes in `BOOT-INF/classes`. This means
that they cannot be found when the executable jar is used as a dependency.
To produce the two artifacts, one that can be used as a dependency and one that is
executable, a classifier must be specified. This classifier is applied to the name of the
executable archive, leaving the default archive for use as dependency.
To configure a classifier of `exec` in Maven, the following configuration can be used:
[source,xml,indent=0,subs="verbatim,quotes,attributes"]
----
...
...
@@ -2667,10 +2677,7 @@ Boot Starter Parent to manage the plugin versions and other configuration defaul
</build>
----
Two jars are produced, the default one, and an executable one using the Boot plugin with
classifier '`exec`'.
For Gradle users the steps are similar. Example:
And when using Gradle, the following configuration can be used:
[source,groovy,indent=0,subs="verbatim,attributes"]
----
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment