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
d477223d
Commit
d477223d
authored
Jan 16, 2017
by
Andy Wilkinson
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '1.5.x'
parents
cf30703f
89e3335c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
133 additions
and
2 deletions
+133
-2
spring-boot-features.adoc
spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc
+10
-0
ServletContextInitializerBeans.java
...work/boot/web/servlet/ServletContextInitializerBeans.java
+2
-2
ServletContextInitializerBeansTests.java
...boot/web/servlet/ServletContextInitializerBeansTests.java
+121
-0
No files found.
spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc
View file @
d477223d
...
...
@@ -3054,6 +3054,16 @@ Hibernate autoconfig is active because the `ddl-auto` settings are more fine-gra
[[boot-features-jpa-in-web-environment]]
==== Open EntityManager in View
If you are running a web application, Spring Boot will by default register
{spring-javadoc}/orm/jpa/support/OpenEntityManagerInViewInterceptor.html[`OpenEntityManagerInViewInterceptor`]
to apply the "Open EntityManager in View" pattern, i.e. to allow for lazy loading in web
views. If you don't want this behavior you should set `spring.jpa.open-in-view` to
`false` in your `application.properties`.
[[boot-features-sql-h2-console]]
=== Using H2's web console
The http://www.h2database.com[H2 database] provides a
...
...
spring-boot/src/main/java/org/springframework/boot/web/servlet/ServletContextInitializerBeans.java
View file @
d477223d
/*
* Copyright 2012-201
6
the original author or authors.
* Copyright 2012-201
7
the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
...
...
@@ -121,7 +121,7 @@ public class ServletContextInitializerBeans
}
else
{
addServletContextInitializerBean
(
ServletContextInitializer
.
class
,
beanName
,
initializer
,
beanFactory
,
null
);
initializer
,
beanFactory
,
initializer
);
}
}
...
...
spring-boot/src/test/java/org/springframework/boot/web/servlet/ServletContextInitializerBeansTests.java
0 → 100644
View file @
d477223d
/*
* Copyright 2012-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org
.
springframework
.
boot
.
web
.
servlet
;
import
java.io.IOException
;
import
javax.servlet.Filter
;
import
javax.servlet.FilterChain
;
import
javax.servlet.FilterConfig
;
import
javax.servlet.ServletContext
;
import
javax.servlet.ServletException
;
import
javax.servlet.ServletRequest
;
import
javax.servlet.ServletResponse
;
import
javax.servlet.http.HttpServlet
;
import
org.junit.Test
;
import
org.springframework.context.ConfigurableApplicationContext
;
import
org.springframework.context.annotation.AnnotationConfigApplicationContext
;
import
org.springframework.context.annotation.Bean
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
/**
* Tests for {@link ServletContextInitializerBeans}.
*
* @author Andy Wilkinson
*/
public
class
ServletContextInitializerBeansTests
{
private
ConfigurableApplicationContext
context
;
@Test
public
void
servletThatImplementsServletContextInitializerIsOnlyRegisteredOnce
()
{
load
(
ServletConfiguration
.
class
);
ServletContextInitializerBeans
initializerBeans
=
new
ServletContextInitializerBeans
(
this
.
context
.
getBeanFactory
());
assertThat
(
initializerBeans
.
size
()).
isEqualTo
(
1
);
assertThat
(
initializerBeans
.
iterator
()).
hasOnlyElementsOfType
(
TestServlet
.
class
);
}
@Test
public
void
filterThatImplementsServletContextInitializerIsOnlyRegisteredOnce
()
{
load
(
FilterConfiguration
.
class
);
ServletContextInitializerBeans
initializerBeans
=
new
ServletContextInitializerBeans
(
this
.
context
.
getBeanFactory
());
assertThat
(
initializerBeans
.
size
()).
isEqualTo
(
1
);
assertThat
(
initializerBeans
.
iterator
()).
hasOnlyElementsOfType
(
TestFilter
.
class
);
}
private
void
load
(
Class
<?>
configuration
)
{
this
.
context
=
new
AnnotationConfigApplicationContext
(
configuration
);
}
static
class
ServletConfiguration
{
@Bean
public
TestServlet
testServlet
()
{
return
new
TestServlet
();
}
}
static
class
FilterConfiguration
{
@Bean
public
TestFilter
testFilter
()
{
return
new
TestFilter
();
}
}
static
class
TestServlet
extends
HttpServlet
implements
ServletContextInitializer
{
@Override
public
void
onStartup
(
ServletContext
servletContext
)
throws
ServletException
{
}
}
static
class
TestFilter
implements
Filter
,
ServletContextInitializer
{
@Override
public
void
onStartup
(
ServletContext
servletContext
)
throws
ServletException
{
}
@Override
public
void
init
(
FilterConfig
filterConfig
)
throws
ServletException
{
}
@Override
public
void
doFilter
(
ServletRequest
request
,
ServletResponse
response
,
FilterChain
chain
)
throws
IOException
,
ServletException
{
}
@Override
public
void
destroy
()
{
}
}
}
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