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
2fe256a8
Commit
2fe256a8
authored
May 01, 2014
by
Phillip Webb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Polish
parent
b568cb1b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
34 deletions
+28
-34
FreeMarkerAutoConfiguration.java
...autoconfigure/freemarker/FreeMarkerAutoConfiguration.java
+28
-34
No files found.
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/freemarker/FreeMarkerAutoConfiguration.java
View file @
2fe256a8
...
...
@@ -55,7 +55,7 @@ import org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver;
@Configuration
@ConditionalOnClass
(
freemarker
.
template
.
Configuration
.
class
)
@AutoConfigureAfter
(
WebMvcAutoConfiguration
.
class
)
public
class
FreeMarkerAutoConfiguration
{
public
class
FreeMarkerAutoConfiguration
implements
EnvironmentAware
{
public
static
final
String
DEFAULT_TEMPLATE_LOADER_PATH
=
"classpath:/templates/"
;
...
...
@@ -63,38 +63,32 @@ public class FreeMarkerAutoConfiguration {
public
static
final
String
DEFAULT_SUFFIX
=
".ftl"
;
@Configuration
public
static
class
FreeMarkerConfigurerConfiguration
implements
EnvironmentAware
{
@Autowired
private
final
ResourceLoader
resourceLoader
=
new
DefaultResourceLoader
();
@Autowired
private
final
ResourceLoader
resourceLoader
=
new
DefaultResourceLoader
();
private
RelaxedPropertyResolver
environment
;
private
RelaxedPropertyResolver
environment
;
@Override
public
void
setEnvironment
(
Environment
environment
)
{
this
.
environment
=
new
RelaxedPropertyResolver
(
environment
,
"spring.freeMarker."
);
}
@Override
public
void
setEnvironment
(
Environment
environment
)
{
this
.
environment
=
new
RelaxedPropertyResolver
(
environment
,
"spring.freeMarker."
);
}
@PostConstruct
public
void
checkTemplateLocationExists
()
{
Boolean
checkTemplateLocation
=
this
.
environment
.
getProperty
(
"checkTemplateLocation"
,
Boolean
.
class
,
true
);
if
(
checkTemplateLocation
)
{
Resource
resource
=
this
.
resourceLoader
.
getResource
(
this
.
environment
.
getProperty
(
"templateLoaderPath"
,
DEFAULT_TEMPLATE_LOADER_PATH
));
Assert
.
state
(
resource
.
exists
(),
"Cannot find template location: "
+
resource
+
" (please add some templates "
+
"or check your FreeMarker configuration)"
);
}
@PostConstruct
public
void
checkTemplateLocationExists
()
{
Boolean
checkTemplateLocation
=
this
.
environment
.
getProperty
(
"checkTemplateLocation"
,
Boolean
.
class
,
true
);
if
(
checkTemplateLocation
)
{
Resource
resource
=
this
.
resourceLoader
.
getResource
(
this
.
environment
.
getProperty
(
"templateLoaderPath"
,
DEFAULT_TEMPLATE_LOADER_PATH
));
Assert
.
state
(
resource
.
exists
(),
"Cannot find template location: "
+
resource
+
" (please add some templates "
+
"or check your FreeMarker configuration)"
);
}
}
@Configuration
@ConditionalOnNotWebApplication
public
static
class
FreeMarkerConfiguration
implements
EnvironmentAware
{
public
static
class
FreeMarker
NonWeb
Configuration
implements
EnvironmentAware
{
private
RelaxedPropertyResolver
environment
;
...
...
@@ -125,7 +119,7 @@ public class FreeMarkerAutoConfiguration {
@Configuration
@ConditionalOnClass
(
Servlet
.
class
)
@ConditionalOnWebApplication
public
static
class
FreeMarker
ViewResolver
Configuration
implements
EnvironmentAware
{
public
static
class
FreeMarker
Web
Configuration
implements
EnvironmentAware
{
private
RelaxedPropertyResolver
environment
;
...
...
@@ -135,14 +129,6 @@ public class FreeMarkerAutoConfiguration {
"spring.freemarker."
);
}
@Bean
@ConditionalOnBean
(
FreeMarkerConfigurer
.
class
)
@ConditionalOnMissingBean
public
freemarker
.
template
.
Configuration
freemarkerConfiguration
(
FreeMarkerConfig
configurer
)
{
return
configurer
.
getConfiguration
();
}
@Bean
@ConditionalOnMissingBean
public
FreeMarkerConfigurer
freeMarkerConfigurer
()
{
...
...
@@ -159,6 +145,14 @@ public class FreeMarkerAutoConfiguration {
return
freeMarkerConfigurer
;
}
@Bean
@ConditionalOnBean
(
FreeMarkerConfigurer
.
class
)
@ConditionalOnMissingBean
public
freemarker
.
template
.
Configuration
freemarkerConfiguration
(
FreeMarkerConfig
configurer
)
{
return
configurer
.
getConfiguration
();
}
@Bean
@ConditionalOnMissingBean
(
name
=
"freeMarkerViewResolver"
)
public
FreeMarkerViewResolver
freeMarkerViewResolver
()
{
...
...
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