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
25cc68ca
Commit
25cc68ca
authored
Jan 17, 2014
by
Christopher Smith
Committed by
Dave Syer
Jan 17, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add spring.resources.cachePeriod to MvcAutoConfiguration
Fixes gh-232
parent
5627caa7
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
26 additions
and
11 deletions
+26
-11
WebMvcAutoConfiguration.java
...ework/boot/autoconfigure/web/WebMvcAutoConfiguration.java
+9
-4
AutoConfigurationReportLoggingInitializerTests.java
...igure/AutoConfigurationReportLoggingInitializerTests.java
+3
-1
DeviceResolverAutoConfigurationTests.java
...onfigure/mobile/DeviceResolverAutoConfigurationTests.java
+3
-1
WebMvcAutoConfigurationTests.java
.../boot/autoconfigure/web/WebMvcAutoConfigurationTests.java
+11
-5
No files found.
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/WebMvcAutoConfiguration.java
View file @
25cc68ca
...
...
@@ -122,6 +122,9 @@ public class WebMvcAutoConfiguration {
@Value
(
"${spring.view.suffix:}"
)
private
String
suffix
=
""
;
@Value
(
"${spring.resources.cachePeriod:}"
)
private
Integer
cachePeriod
;
@Autowired
private
ListableBeanFactory
beanFactory
;
...
...
@@ -193,12 +196,14 @@ public class WebMvcAutoConfiguration {
@Override
public
void
addResourceHandlers
(
ResourceHandlerRegistry
registry
)
{
if
(!
registry
.
hasMappingForPattern
(
"/webjars/**"
))
{
registry
.
addResourceHandler
(
"/webjars/**"
).
addResourceLocations
(
"classpath:/META-INF/resources/webjars/"
);
registry
.
addResourceHandler
(
"/webjars/**"
)
.
addResourceLocations
(
"classpath:/META-INF/resources/webjars/"
)
.
setCachePeriod
(
this
.
cachePeriod
);
}
if
(!
registry
.
hasMappingForPattern
(
"/**"
))
{
registry
.
addResourceHandler
(
"/**"
).
addResourceLocations
(
RESOURCE_LOCATIONS
);
registry
.
addResourceHandler
(
"/**"
)
.
addResourceLocations
(
RESOURCE_LOCATIONS
)
.
setCachePeriod
(
this
.
cachePeriod
);
}
}
...
...
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/AutoConfigurationReportLoggingInitializerTests.java
View file @
25cc68ca
...
...
@@ -208,7 +208,9 @@ public class AutoConfigurationReportLoggingInitializerTests {
}
@Configuration
@Import
({
WebMvcAutoConfiguration
.
class
,
HttpMessageConvertersAutoConfiguration
.
class
})
@Import
({
WebMvcAutoConfiguration
.
class
,
HttpMessageConvertersAutoConfiguration
.
class
,
PropertyPlaceholderAutoConfiguration
.
class
})
static
class
Config
{
}
...
...
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/mobile/DeviceResolverAutoConfigurationTests.java
View file @
25cc68ca
...
...
@@ -21,6 +21,7 @@ import java.util.List;
import
org.junit.After
;
import
org.junit.Test
;
import
org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration
;
import
org.springframework.boot.autoconfigure.web.HttpMessageConvertersAutoConfiguration
;
import
org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration
;
import
org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext
;
...
...
@@ -78,7 +79,8 @@ public class DeviceResolverAutoConfigurationTests {
AnnotationConfigEmbeddedWebApplicationContext
context
=
new
AnnotationConfigEmbeddedWebApplicationContext
();
context
.
register
(
Config
.
class
,
WebMvcAutoConfiguration
.
class
,
HttpMessageConvertersAutoConfiguration
.
class
,
DeviceResolverAutoConfiguration
.
class
);
DeviceResolverAutoConfiguration
.
class
,
PropertyPlaceholderAutoConfiguration
.
class
);
context
.
refresh
();
RequestMappingHandlerMapping
mapping
=
(
RequestMappingHandlerMapping
)
context
.
getBean
(
"requestMappingHandlerMapping"
);
...
...
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/WebMvcAutoConfigurationTests.java
View file @
25cc68ca
...
...
@@ -28,6 +28,7 @@ import org.junit.After;
import
org.junit.Rule
;
import
org.junit.Test
;
import
org.junit.rules.ExpectedException
;
import
org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration
;
import
org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext
;
import
org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizerBeanPostProcessor
;
import
org.springframework.boot.context.embedded.EmbeddedServletContainerFactory
;
...
...
@@ -78,7 +79,8 @@ public class WebMvcAutoConfigurationTests {
public
void
handerAdaptersCreated
()
throws
Exception
{
this
.
context
=
new
AnnotationConfigEmbeddedWebApplicationContext
();
this
.
context
.
register
(
Config
.
class
,
WebMvcAutoConfiguration
.
class
,
HttpMessageConvertersAutoConfiguration
.
class
);
HttpMessageConvertersAutoConfiguration
.
class
,
PropertyPlaceholderAutoConfiguration
.
class
);
this
.
context
.
refresh
();
assertEquals
(
3
,
this
.
context
.
getBeanNamesForType
(
HandlerAdapter
.
class
).
length
);
assertFalse
(
this
.
context
.
getBean
(
RequestMappingHandlerAdapter
.
class
)
...
...
@@ -92,7 +94,8 @@ public class WebMvcAutoConfigurationTests {
public
void
handerMappingsCreated
()
throws
Exception
{
this
.
context
=
new
AnnotationConfigEmbeddedWebApplicationContext
();
this
.
context
.
register
(
Config
.
class
,
WebMvcAutoConfiguration
.
class
,
HttpMessageConvertersAutoConfiguration
.
class
);
HttpMessageConvertersAutoConfiguration
.
class
,
PropertyPlaceholderAutoConfiguration
.
class
);
this
.
context
.
refresh
();
assertEquals
(
6
,
this
.
context
.
getBeanNamesForType
(
HandlerMapping
.
class
).
length
);
}
...
...
@@ -101,7 +104,8 @@ public class WebMvcAutoConfigurationTests {
public
void
resourceHandlerMapping
()
throws
Exception
{
this
.
context
=
new
AnnotationConfigEmbeddedWebApplicationContext
();
this
.
context
.
register
(
Config
.
class
,
WebMvcAutoConfiguration
.
class
,
HttpMessageConvertersAutoConfiguration
.
class
);
HttpMessageConvertersAutoConfiguration
.
class
,
PropertyPlaceholderAutoConfiguration
.
class
);
this
.
context
.
refresh
();
Map
<
String
,
List
<
Resource
>>
mappingLocations
=
getMappingLocations
();
assertThat
(
mappingLocations
.
get
(
"/**"
).
size
(),
equalTo
(
5
));
...
...
@@ -114,7 +118,8 @@ public class WebMvcAutoConfigurationTests {
public
void
resourceHandlerMappingOverrideWebjars
()
throws
Exception
{
this
.
context
=
new
AnnotationConfigEmbeddedWebApplicationContext
();
this
.
context
.
register
(
WebJars
.
class
,
Config
.
class
,
WebMvcAutoConfiguration
.
class
,
HttpMessageConvertersAutoConfiguration
.
class
);
HttpMessageConvertersAutoConfiguration
.
class
,
PropertyPlaceholderAutoConfiguration
.
class
);
this
.
context
.
refresh
();
Map
<
String
,
List
<
Resource
>>
mappingLocations
=
getMappingLocations
();
assertThat
(
mappingLocations
.
get
(
"/webjars/**"
).
size
(),
equalTo
(
1
));
...
...
@@ -127,7 +132,8 @@ public class WebMvcAutoConfigurationTests {
this
.
context
=
new
AnnotationConfigEmbeddedWebApplicationContext
();
this
.
context
.
register
(
AllResources
.
class
,
Config
.
class
,
WebMvcAutoConfiguration
.
class
,
HttpMessageConvertersAutoConfiguration
.
class
);
HttpMessageConvertersAutoConfiguration
.
class
,
PropertyPlaceholderAutoConfiguration
.
class
);
this
.
context
.
refresh
();
Map
<
String
,
List
<
Resource
>>
mappingLocations
=
getMappingLocations
();
assertThat
(
mappingLocations
.
get
(
"/**"
).
size
(),
equalTo
(
1
));
...
...
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