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
5cb8e410
Commit
5cb8e410
authored
Mar 18, 2014
by
Phillip Webb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Polish docs
Minoir polish for wrapping at 90 and tabs instead of spaces.
parent
5ce1bdfb
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
60 additions
and
64 deletions
+60
-64
build-tool-plugins.adoc
spring-boot-docs/src/main/asciidoc/build-tool-plugins.adoc
+25
-24
howto.adoc
spring-boot-docs/src/main/asciidoc/howto.adoc
+12
-13
spring-boot-features.adoc
spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc
+23
-27
No files found.
spring-boot-docs/src/main/asciidoc/build-tool-plugins.adoc
View file @
5cb8e410
...
@@ -125,8 +125,8 @@ To build and run a project artifact, you can type the following:
...
@@ -125,8 +125,8 @@ To build and run a project artifact, you can type the following:
$
java
-
jar
target
/
mymodule
-
0.0.1
-
SNAPSHOT
.
jar
$
java
-
jar
target
/
mymodule
-
0.0.1
-
SNAPSHOT
.
jar
----
----
To
build
a
war
file
that
is
both
executable
and
deployable
into
an
external
container
To
build
a
war
file
that
is
both
executable
and
deployable
into
an
external
container
you
you
need
to
mark
the
embedded
container
dependencies
as
"provided"
,
e
.
g
.
need
to
mark
the
embedded
container
dependencies
as
``
provided
''
,
e
.
g
:
[
source
,
xml
,
indent
=
0
,
subs
=
"verbatim,attributes"
]
[
source
,
xml
,
indent
=
0
,
subs
=
"verbatim,attributes"
]
----
----
...
@@ -136,7 +136,7 @@ you need to mark the embedded container dependencies as "provided", e.g.
...
@@ -136,7 +136,7 @@ you need to mark the embedded container dependencies as "provided", e.g.
<
!-- ... -->
<
!-- ... -->
<
packaging
>
war
</
packaging
>
<
packaging
>
war
</
packaging
>
<
!-- ... -->
<
!-- ... -->
<
dependencies
>
<
dependencies
>
<
dependency
>
<
dependency
>
<
groupId
>
org
.
springframework
.
boot
</
groupId
>
<
groupId
>
org
.
springframework
.
boot
</
groupId
>
<
artifactId
>
spring
-
boot
-
starter
-
web
</
artifactId
>
<
artifactId
>
spring
-
boot
-
starter
-
web
</
artifactId
>
...
@@ -147,11 +147,12 @@ you need to mark the embedded container dependencies as "provided", e.g.
...
@@ -147,11 +147,12 @@ you need to mark the embedded container dependencies as "provided", e.g.
<
scope
>
provided
</
scope
>
<
scope
>
provided
</
scope
>
</
dependency
>
</
dependency
>
<
!-- ... -->
<
!-- ... -->
</
dependencies
>
</
dependencies
>
</
project
>
</
project
>
----
----
[[
build
-
tool
-
plugins
-
maven
-
packaging
-
configuration
]]
[[
build
-
tool
-
plugins
-
maven
-
packaging
-
configuration
]]
===
Repackage
configuration
===
Repackage
configuration
The
following
configuration
options
are
available
for
the
`
spring
-
boot
:
repackage
`
goal
:
The
following
configuration
options
are
available
for
the
`
spring
-
boot
:
repackage
`
goal
:
...
@@ -373,33 +374,33 @@ To build and run a project artifact, you can type the following:
...
@@ -373,33 +374,33 @@ To build and run a project artifact, you can type the following:
----
----
To
build
a
war
file
that
is
both
executable
and
deployable
into
an
external
container
,
To
build
a
war
file
that
is
both
executable
and
deployable
into
an
external
container
,
you
need
to
mark
the
embedded
container
dependencies
as
belonging
to
a
configuration
you
need
to
mark
the
embedded
container
dependencies
as
belonging
to
a
configuration
named
"providedRuntime"
,
e
.
g
.
named
"providedRuntime"
,
e
.
g
:
[
source
,
groovy
,
indent
=
0
,
subs
=
"verbatim,attributes"
]
[
source
,
groovy
,
indent
=
0
,
subs
=
"verbatim,attributes"
]
----
----
...
...
apply
plugin
:
'war'
apply
plugin
:
'war'
war
{
war
{
baseName
=
'myapp'
baseName
=
'myapp'
version
=
'0.5.0'
version
=
'0.5.0'
}
}
repositories
{
repositories
{
mavenCentral
()
mavenCentral
()
maven
{
url
"http://repo.spring.io/libs-snapshot"
}
maven
{
url
"http://repo.spring.io/libs-snapshot"
}
}
}
configurations
{
configurations
{
providedRuntime
providedRuntime
}
}
dependencies
{
dependencies
{
compile
(
"org.springframework.boot:spring-boot-starter-web"
)
compile
(
"org.springframework.boot:spring-boot-starter-web"
)
providedRuntime
(
"org.springframework.boot:spring-boot-starter-tomcat"
)
providedRuntime
(
"org.springframework.boot:spring-boot-starter-tomcat"
)
...
...
}
}
----
----
...
...
spring-boot-docs/src/main/asciidoc/howto.adoc
View file @
5cb8e410
...
@@ -355,30 +355,29 @@ that and be sure that it has initialized is to add a `@Bean` of type
...
@@ -355,30 +355,29 @@ that and be sure that it has initialized is to add a `@Bean` of type
`ApplicationListener<EmbeddedServletContainerInitializedEvent>` and pull the container
`ApplicationListener<EmbeddedServletContainerInitializedEvent>` and pull the container
out of the event when it is published.
out of the event when it is published.
A really useful thing to do in is to autowire the
A really useful thing to do in is to autowire the `EmbeddedWebApplicationContext` into a
`EmbeddedWebApplicationContext` into a test case and use it to
test case and use it to discover the port that the app is running on. In that way you can
discover the port that the app is running on. In that way you can use
use a test profile that chooses a random port (`server.port=0`) and make your test suite
a test profile that chooses a random port (`server.port=0`) and make
independent of its environment. Example:
your test suite independent of its environment. Example:
[source,java,indent=0,subs="verbatim,quotes,attributes"]
[source,java,indent=0,subs="verbatim,quotes,attributes"]
----
----
@RunWith(SpringJUnit4ClassRunner.class)
@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes = SampleDataJpaApplication.class)
@SpringApplicationConfiguration(classes = SampleDataJpaApplication.class)
@WebApplication
@WebApplication
@IntegrationTest
@IntegrationTest
@ActiveProfiles("test")
@ActiveProfiles("test")
public class CityRepositoryIntegrationTests {
public class CityRepositoryIntegrationTests {
@Autowired
@Autowired
EmbeddedWebApplicationContext server;
EmbeddedWebApplicationContext server;
int port;
int port;
@Before
@Before
public void init() {
public void init() {
port = server.getEmbeddedServletContainer().getPort();
port = server.getEmbeddedServletContainer().getPort();
}
}
// ...
// ...
...
...
spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc
View file @
5cb8e410
...
@@ -1430,38 +1430,35 @@ For example:
...
@@ -1430,38 +1430,35 @@ For example:
}
}
----
----
TIP: The context loader guesses whether you want to test a web application or not (e.g.
with
TIP: The context loader guesses whether you want to test a web application or not (e.g.
`MockMVC`) by looking for the `@WebAppConfiguration` annotation. (`MockMVC` and
with
`MockMVC`) by looking for the `@WebAppConfiguration` annotation. (`MockMVC` and
`@WebAppConfiguration` are part of `spring-test`).
`@WebAppConfiguration` are part of `spring-test`).
If you want a web application to start up and listen on its normal
If you want a web application to start up and listen on its normal port, so you can test
port, so you can test it with HTTP (e.g. using `RestTemplate`)
it with HTTP (e.g. using `RestTemplate`), annotate your test class (or one of its
annotate your test class (or one of its superclasses)
superclasses) with `@IntegrationTest`. This can be very useful because it means you can
`@IntegrationTest`. This can be very useful because it means you can
test the full stack of your application, but also inject its components into the test
test the full stack of your application, but also inject its
class and use them to assert the internal state of the application after an HTTP
components into the test class and use them to assert the internal
interaction. For Example:
state of the application after an HTTP interaction. Example:
[source,java,indent=0,subs="verbatim,quotes,attributes"]
[source,java,indent=0,subs="verbatim,quotes,attributes"]
----
----
@RunWith(SpringJUnit4ClassRunner.class)
@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes = SampleDataJpaApplication.class)
@SpringApplicationConfiguration(classes = SampleDataJpaApplication.class)
@WebApplication
@WebApplication
@IntegrationTest
@IntegrationTest
public class CityRepositoryIntegrationTests {
public class CityRepositoryIntegrationTests {
@Autowired
@Autowired
CityRepository repository;
CityRepository repository;
RestTemplate restTemplate = RestTemplates.get();
RestTemplate restTemplate = RestTemplates.get();
// ... interact with the running server
// ... interact with the running server
}
}
----
----
[[boot-features-test-utilities]]
[[boot-features-test-utilities]]
=== Test utilities
=== Test utilities
A few test utility classes are packaged as part of `spring-boot` that are generally
A few test utility classes are packaged as part of `spring-boot` that are generally
...
@@ -1528,26 +1525,24 @@ public class MyTest {
...
@@ -1528,26 +1525,24 @@ public class MyTest {
[[boot-features-rest-templates-test-utility]]
[[boot-features-rest-templates-test-utility]]
==== RestTemplates
==== RestTemplates
`RestTemplates` is a static convenience factory for instances of
`RestTemplates` is a static convenience factory for instances of `RestTemplate` that are
`RestTemplate` that are useful in integration tests. You can get a
useful in integration tests. You can get a vanilla template or one that sends Basic HTTP
vanilla template or one that sends Basic HTTP authentication (with a
authentication (with a username and password). And in either case the template will behave
username and password). And in either case the template will behave in
in a friendly way for testing, not following redirects (so you can assert the response
a friendly way for testing, not following redirects (so you can assert
location), ignoring cookies (so the template is stateless), and not throwing exceptions
the response location), ignoring cookies (so the template is
on server-side errors. It is recommended, but not mandatory, to use Apache HTTP Client
stateless), and not throwing exceptions on server-side errors. It is
(version 4.3.2 or better), and if you have that on your classpath the `RestTemplates` will
recommended, but not mandatory, to use Apache HTTP Client (version
respond by configuring the client appropriately.
4.3.2 or better), and if you have that on your classpath the
`RestTemplates` will respond by configuring the client appropriately.
[source,java,indent=0]
[source,java,indent=0]
----
----
public class MyTest {
public class MyTest {
RestTemplate template = RestTemplates.get();
RestTemplate template = RestTemplates.get();
@Test
@Test
public void testRequest() throws Exception {
public void testRequest() throws Exception {
HttpHeaders headers = template.getForEntity("http://myhost.com", String.class).getHeaders();
HttpHeaders headers = template.getForEntity("http://myhost.com", String.class).getHeaders();
assertThat(headers.getLocation().toString(), containsString("myotherhost"));
assertThat(headers.getLocation().toString(), containsString("myotherhost"));
}
}
...
@@ -1555,6 +1550,7 @@ public class MyTest {
...
@@ -1555,6 +1550,7 @@ public class MyTest {
----
----
[[boot-features-developing-auto-configuration]]
[[boot-features-developing-auto-configuration]]
== Developing auto-configuration and using conditions
== Developing auto-configuration and using conditions
If you work in a company that develops shared libraries, or if you work on an open-source
If you work in a company that develops shared libraries, or if you work on an open-source
...
...
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