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
f4dcef28
Commit
f4dcef28
authored
Sep 03, 2015
by
Phillip Webb
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '1.2.x'
parents
efee06fd
adf2c44b
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
25 additions
and
15 deletions
+25
-15
pom.xml
spring-boot-deployment-tests/pom.xml
+0
-3
SampleSimpleApplication.java
.../src/main/java/sample/simple/SampleSimpleApplication.java
+4
-0
SpringApplication.java
...main/java/org/springframework/boot/SpringApplication.java
+20
-12
SpringApplicationContextLoader.java
...ngframework/boot/test/SpringApplicationContextLoader.java
+1
-0
No files found.
spring-boot-deployment-tests/pom.xml
View file @
f4dcef28
...
@@ -19,7 +19,6 @@
...
@@ -19,7 +19,6 @@
<properties>
<properties>
<main.basedir>
${basedir}/..
</main.basedir>
<main.basedir>
${basedir}/..
</main.basedir>
<java.version>
1.7
</java.version>
<java.version>
1.7
</java.version>
<cargo.timeout>
300000
</cargo.timeout>
<cargo.timeout>
300000
</cargo.timeout>
<cargo.container.download-dir>
${user.home}/.cargo/installs
</cargo.container.download-dir>
<cargo.container.download-dir>
${user.home}/.cargo/installs
</cargo.container.download-dir>
</properties>
</properties>
...
@@ -28,7 +27,6 @@
...
@@ -28,7 +27,6 @@
<module>
spring-boot-deployment-test-tomcat
</module>
<module>
spring-boot-deployment-test-tomcat
</module>
<module>
spring-boot-deployment-test-wildfly
</module>
<module>
spring-boot-deployment-test-wildfly
</module>
</modules>
</modules>
<build>
<build>
<pluginManagement>
<pluginManagement>
<plugins>
<plugins>
...
@@ -74,5 +72,4 @@
...
@@ -74,5 +72,4 @@
</plugins>
</plugins>
</pluginManagement>
</pluginManagement>
</build>
</build>
</project>
</project>
spring-boot-samples/spring-boot-sample-simple/src/main/java/sample/simple/SampleSimpleApplication.java
View file @
f4dcef28
...
@@ -20,6 +20,7 @@ import org.springframework.beans.factory.annotation.Autowired;
...
@@ -20,6 +20,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.boot.CommandLineRunner
;
import
org.springframework.boot.CommandLineRunner
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
import
org.springframework.context.annotation.AnnotationConfigApplicationContext
;
import
sample.simple.service.HelloWorldService
;
import
sample.simple.service.HelloWorldService
;
...
@@ -39,6 +40,9 @@ public class SampleSimpleApplication implements CommandLineRunner {
...
@@ -39,6 +40,9 @@ public class SampleSimpleApplication implements CommandLineRunner {
}
}
public
static
void
main
(
String
[]
args
)
throws
Exception
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
SpringApplication
application
=
new
SpringApplication
(
SampleSimpleApplication
.
class
);
application
.
setApplicationContextClass
(
AnnotationConfigApplicationContext
.
class
);
SpringApplication
.
run
(
SampleSimpleApplication
.
class
,
args
);
SpringApplication
.
run
(
SampleSimpleApplication
.
class
,
args
);
}
}
...
...
spring-boot/src/main/java/org/springframework/boot/SpringApplication.java
View file @
f4dcef28
...
@@ -226,12 +226,21 @@ public class SpringApplication {
...
@@ -226,12 +226,21 @@ public class SpringApplication {
if
(
sources
!=
null
&&
sources
.
length
>
0
)
{
if
(
sources
!=
null
&&
sources
.
length
>
0
)
{
this
.
sources
.
addAll
(
Arrays
.
asList
(
sources
));
this
.
sources
.
addAll
(
Arrays
.
asList
(
sources
));
}
}
this
.
webEnvironment
=
isSpringWebAvailable
();
this
.
webEnvironment
=
deduceWebEnvironment
();
setInitializers
((
Collection
)
getSpringFactoriesInstances
(
ApplicationContextInitializer
.
class
));
setInitializers
((
Collection
)
getSpringFactoriesInstances
(
ApplicationContextInitializer
.
class
));
setListeners
((
Collection
)
getSpringFactoriesInstances
(
ApplicationListener
.
class
));
setListeners
((
Collection
)
getSpringFactoriesInstances
(
ApplicationListener
.
class
));
this
.
mainApplicationClass
=
deduceMainApplicationClass
();
this
.
mainApplicationClass
=
deduceMainApplicationClass
();
}
}
private
boolean
deduceWebEnvironment
()
{
for
(
String
className
:
WEB_ENVIRONMENT_CLASSES
)
{
if
(!
ClassUtils
.
isPresent
(
className
,
null
))
{
return
false
;
}
}
return
true
;
}
private
Class
<?>
deduceMainApplicationClass
()
{
private
Class
<?>
deduceMainApplicationClass
()
{
try
{
try
{
StackTraceElement
[]
stackTrace
=
new
RuntimeException
().
getStackTrace
();
StackTraceElement
[]
stackTrace
=
new
RuntimeException
().
getStackTrace
();
...
@@ -877,12 +886,20 @@ public class SpringApplication {
...
@@ -877,12 +886,20 @@ public class SpringApplication {
public
void
setApplicationContextClass
(
public
void
setApplicationContextClass
(
Class
<?
extends
ConfigurableApplicationContext
>
applicationContextClass
)
{
Class
<?
extends
ConfigurableApplicationContext
>
applicationContextClass
)
{
this
.
applicationContextClass
=
applicationContextClass
;
this
.
applicationContextClass
=
applicationContextClass
;
if
(!
isSpringWebAvailable
()
if
(!
isWebApplicationContext
(
applicationContextClass
))
{
||
!
WebApplicationContext
.
class
.
isAssignableFrom
(
applicationContextClass
))
{
this
.
webEnvironment
=
false
;
this
.
webEnvironment
=
false
;
}
}
}
}
private
boolean
isWebApplicationContext
(
Class
<?>
applicationContextClass
)
{
try
{
return
WebApplicationContext
.
class
.
isAssignableFrom
(
applicationContextClass
);
}
catch
(
NoClassDefFoundError
ex
)
{
return
false
;
}
}
/**
/**
* Sets the {@link ApplicationContextInitializer} that will be applied to the Spring
* Sets the {@link ApplicationContextInitializer} that will be applied to the Spring
* {@link ApplicationContext}.
* {@link ApplicationContext}.
...
@@ -941,15 +958,6 @@ public class SpringApplication {
...
@@ -941,15 +958,6 @@ public class SpringApplication {
return
asUnmodifiableOrderedSet
(
this
.
listeners
);
return
asUnmodifiableOrderedSet
(
this
.
listeners
);
}
}
private
boolean
isSpringWebAvailable
()
{
for
(
String
className
:
WEB_ENVIRONMENT_CLASSES
)
{
if
(!
ClassUtils
.
isPresent
(
className
,
null
))
{
return
false
;
}
}
return
true
;
}
/**
/**
* Static helper that can be used to run a {@link SpringApplication} from the
* Static helper that can be used to run a {@link SpringApplication} from the
* specified source using default settings.
* specified source using default settings.
...
...
spring-boot/src/main/java/org/springframework/boot/test/SpringApplicationContextLoader.java
View file @
f4dcef28
...
@@ -81,6 +81,7 @@ public class SpringApplicationContextLoader extends AbstractContextLoader {
...
@@ -81,6 +81,7 @@ public class SpringApplicationContextLoader extends AbstractContextLoader {
throws
Exception
{
throws
Exception
{
assertValidAnnotations
(
config
.
getTestClass
());
assertValidAnnotations
(
config
.
getTestClass
());
SpringApplication
application
=
getSpringApplication
();
SpringApplication
application
=
getSpringApplication
();
application
.
setRegisterShutdownHook
(
false
);
application
.
setMainApplicationClass
(
config
.
getTestClass
());
application
.
setMainApplicationClass
(
config
.
getTestClass
());
application
.
setSources
(
getSources
(
config
));
application
.
setSources
(
getSources
(
config
));
ConfigurableEnvironment
environment
=
new
StandardEnvironment
();
ConfigurableEnvironment
environment
=
new
StandardEnvironment
();
...
...
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