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
3404850b
Commit
3404850b
authored
Aug 26, 2014
by
Dave Syer
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '1.1.x'
parents
fcebf9d3
95d65c2f
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
181 additions
and
18 deletions
+181
-18
FreeMarkerProperties.java
...k/boot/autoconfigure/freemarker/FreeMarkerProperties.java
+0
-8
AbstractTemplateViewResolverProperties.java
...gure/template/AbstractTemplateViewResolverProperties.java
+13
-3
VelocityAutoConfiguration.java
...oot/autoconfigure/velocity/VelocityAutoConfiguration.java
+1
-1
VelocityProperties.java
...ework/boot/autoconfigure/velocity/VelocityProperties.java
+4
-6
pom.xml
spring-boot-samples/pom.xml
+1
-0
pom.xml
spring-boot-samples/spring-boot-sample-velocity/pom.xml
+56
-0
SampleVelocityApplication.java
.../main/java/sample/velocity/SampleVelocityApplication.java
+57
-0
application.properties
...sample-velocity/src/main/resources/application.properties
+1
-0
welcome.vm
...t-sample-velocity/src/main/resources/templates/welcome.vm
+2
-0
SampleVelocityApplicationTests.java
.../java/sample/velocity/SampleVelocityApplicationTests.java
+46
-0
No files found.
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/freemarker/FreeMarkerProperties.java
View file @
3404850b
...
@@ -21,7 +21,6 @@ import java.util.Map;
...
@@ -21,7 +21,6 @@ import java.util.Map;
import
org.springframework.boot.autoconfigure.template.AbstractTemplateViewResolverProperties
;
import
org.springframework.boot.autoconfigure.template.AbstractTemplateViewResolverProperties
;
import
org.springframework.boot.context.properties.ConfigurationProperties
;
import
org.springframework.boot.context.properties.ConfigurationProperties
;
import
org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver
;
/**
/**
* {@link ConfigurationProperties} for configuring FreeMarker
* {@link ConfigurationProperties} for configuring FreeMarker
...
@@ -63,11 +62,4 @@ public class FreeMarkerProperties extends AbstractTemplateViewResolverProperties
...
@@ -63,11 +62,4 @@ public class FreeMarkerProperties extends AbstractTemplateViewResolverProperties
this
.
templateLoaderPath
=
templateLoaderPath
;
this
.
templateLoaderPath
=
templateLoaderPath
;
}
}
/**
* Apply the given properties to a {@link FreeMarkerViewResolver}.
* @param resolver the resolver to apply the properties to.
*/
public
void
applyToViewResolver
(
FreeMarkerViewResolver
resolver
)
{
super
.
applyToViewResolver
(
resolver
);
}
}
}
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/template/AbstractTemplateViewResolverProperties.java
View file @
3404850b
...
@@ -18,6 +18,7 @@ package org.springframework.boot.autoconfigure.template;
...
@@ -18,6 +18,7 @@ package org.springframework.boot.autoconfigure.template;
import
org.springframework.boot.context.properties.ConfigurationProperties
;
import
org.springframework.boot.context.properties.ConfigurationProperties
;
import
org.springframework.core.Ordered
;
import
org.springframework.core.Ordered
;
import
org.springframework.util.Assert
;
import
org.springframework.web.servlet.view.AbstractTemplateViewResolver
;
import
org.springframework.web.servlet.view.AbstractTemplateViewResolver
;
/**
/**
...
@@ -158,10 +159,18 @@ public abstract class AbstractTemplateViewResolverProperties {
...
@@ -158,10 +159,18 @@ public abstract class AbstractTemplateViewResolverProperties {
}
}
/**
/**
* Apply the given properties to a {@link AbstractTemplateViewResolver}.
* Apply the given properties to a {@link AbstractTemplateViewResolver}. Use Object in
* @param resolver the resolver to apply the properties to.
* signature to avoid runtime dependency on MVC, which means that the template engine
* can be used in a non-web application.
*
* @param viewResolver the resolver to apply the properties to.
*/
*/
protected
void
applyToViewResolver
(
AbstractTemplateViewResolver
resolver
)
{
public
void
applyToViewResolver
(
Object
viewResolver
)
{
Assert
.
isInstanceOf
(
AbstractTemplateViewResolver
.
class
,
viewResolver
,
"ViewResolver is not an instance of AbstractTemplateViewResolver :"
+
viewResolver
);
AbstractTemplateViewResolver
resolver
=
(
AbstractTemplateViewResolver
)
viewResolver
;
resolver
.
setPrefix
(
getPrefix
());
resolver
.
setPrefix
(
getPrefix
());
resolver
.
setSuffix
(
getSuffix
());
resolver
.
setSuffix
(
getSuffix
());
resolver
.
setCache
(
isCache
());
resolver
.
setCache
(
isCache
());
...
@@ -175,6 +184,7 @@ public abstract class AbstractTemplateViewResolverProperties {
...
@@ -175,6 +184,7 @@ public abstract class AbstractTemplateViewResolverProperties {
// The resolver usually acts as a fallback resolver (e.g. like a
// The resolver usually acts as a fallback resolver (e.g. like a
// InternalResourceViewResolver) so it needs to have low precedence
// InternalResourceViewResolver) so it needs to have low precedence
resolver
.
setOrder
(
Ordered
.
LOWEST_PRECEDENCE
-
5
);
resolver
.
setOrder
(
Ordered
.
LOWEST_PRECEDENCE
-
5
);
}
}
}
}
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/velocity/VelocityAutoConfiguration.java
View file @
3404850b
...
@@ -118,7 +118,7 @@ public class VelocityAutoConfiguration {
...
@@ -118,7 +118,7 @@ public class VelocityAutoConfiguration {
@Bean
@Bean
public
VelocityEngine
velocityEngine
(
VelocityConfigurer
configurer
)
public
VelocityEngine
velocityEngine
(
VelocityConfigurer
configurer
)
throws
VelocityException
,
IOException
{
throws
VelocityException
,
IOException
{
return
configurer
.
create
VelocityEngine
();
return
configurer
.
get
VelocityEngine
();
}
}
@Bean
@Bean
...
...
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/velocity/VelocityProperties.java
View file @
3404850b
...
@@ -92,12 +92,10 @@ public class VelocityProperties extends AbstractTemplateViewResolverProperties {
...
@@ -92,12 +92,10 @@ public class VelocityProperties extends AbstractTemplateViewResolverProperties {
this
.
toolboxConfigLocation
=
toolboxConfigLocation
;
this
.
toolboxConfigLocation
=
toolboxConfigLocation
;
}
}
/**
@Override
* Apply the given properties to a {@link VelocityViewResolver}.
public
void
applyToViewResolver
(
Object
viewResolver
)
{
* @param resolver the resolver to apply the properties to.
super
.
applyToViewResolver
(
viewResolver
);
*/
VelocityViewResolver
resolver
=
(
VelocityViewResolver
)
viewResolver
;
public
void
applyToViewResolver
(
VelocityViewResolver
resolver
)
{
super
.
applyToViewResolver
(
resolver
);
resolver
.
setToolboxConfigLocation
(
getToolboxConfigLocation
());
resolver
.
setToolboxConfigLocation
(
getToolboxConfigLocation
());
resolver
.
setDateToolAttribute
(
getDateToolAttribute
());
resolver
.
setDateToolAttribute
(
getDateToolAttribute
());
resolver
.
setNumberToolAttribute
(
getNumberToolAttribute
());
resolver
.
setNumberToolAttribute
(
getNumberToolAttribute
());
...
...
spring-boot-samples/pom.xml
View file @
3404850b
...
@@ -49,6 +49,7 @@
...
@@ -49,6 +49,7 @@
<module>
spring-boot-sample-tomcat-multi-connectors
</module>
<module>
spring-boot-sample-tomcat-multi-connectors
</module>
<module>
spring-boot-sample-tomcat8-jsp
</module>
<module>
spring-boot-sample-tomcat8-jsp
</module>
<module>
spring-boot-sample-traditional
</module>
<module>
spring-boot-sample-traditional
</module>
<module>
spring-boot-sample-velocity
</module>
<module>
spring-boot-sample-web-freemarker
</module>
<module>
spring-boot-sample-web-freemarker
</module>
<module>
spring-boot-sample-web-groovy-templates
</module>
<module>
spring-boot-sample-web-groovy-templates
</module>
<module>
spring-boot-sample-web-method-security
</module>
<module>
spring-boot-sample-web-method-security
</module>
...
...
spring-boot-samples/spring-boot-sample-velocity/pom.xml
0 → 100644
View file @
3404850b
<?xml version="1.0" encoding="UTF-8"?>
<project
xmlns=
"http://maven.apache.org/POM/4.0.0"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
>
<modelVersion>
4.0.0
</modelVersion>
<parent>
<!-- Your own application should inherit from spring-boot-starter-parent -->
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-samples
</artifactId>
<version>
1.1.6.BUILD-SNAPSHOT
</version>
</parent>
<artifactId>
spring-boot-sample-velocity
</artifactId>
<name>
spring-boot-sample-velocity
</name>
<description>
Spring Boot Web Velocity Sample
</description>
<url>
http://projects.spring.io/spring-boot/
</url>
<organization>
<name>
Pivotal Software, Inc.
</name>
<url>
http://www.spring.io
</url>
</organization>
<properties>
<main.basedir>
${basedir}/../..
</main.basedir>
<m2eclipse.wtp.contextRoot>
/
</m2eclipse.wtp.contextRoot>
</properties>
<dependencies>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter
</artifactId>
</dependency>
<dependency>
<groupId>
org.springframework
</groupId>
<artifactId>
spring-context-support
</artifactId>
</dependency>
<dependency>
<groupId>
org.apache.velocity
</groupId>
<artifactId>
velocity
</artifactId>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-test
</artifactId>
<scope>
test
</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-maven-plugin
</artifactId>
</plugin>
<plugin>
<groupId>
org.apache.maven.plugins
</groupId>
<artifactId>
maven-surefire-plugin
</artifactId>
<configuration>
<useSystemClassLoader>
false
</useSystemClassLoader>
</configuration>
</plugin>
</plugins>
</build>
</project>
spring-boot-samples/spring-boot-sample-velocity/src/main/java/sample/velocity/SampleVelocityApplication.java
0 → 100644
View file @
3404850b
/*
* Copyright 2012-2014 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
sample
.
velocity
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.Map
;
import
org.apache.velocity.app.VelocityEngine
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.boot.CommandLineRunner
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.autoconfigure.EnableAutoConfiguration
;
import
org.springframework.context.annotation.ComponentScan
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.ui.velocity.VelocityEngineUtils
;
@Configuration
@EnableAutoConfiguration
@ComponentScan
public
class
SampleVelocityApplication
implements
CommandLineRunner
{
@Value
(
"${application.message}"
)
private
String
message
;
@Autowired
private
VelocityEngine
engine
;
@Override
public
void
run
(
String
...
args
)
throws
Exception
{
Map
<
String
,
Object
>
model
=
new
HashMap
<
String
,
Object
>();
model
.
put
(
"time"
,
new
Date
());
model
.
put
(
"message"
,
this
.
message
);
System
.
out
.
println
(
VelocityEngineUtils
.
mergeTemplateIntoString
(
this
.
engine
,
"welcome.vm"
,
"UTF-8"
,
model
));
}
public
static
void
main
(
String
[]
args
)
throws
Exception
{
SpringApplication
.
run
(
SampleVelocityApplication
.
class
,
args
);
}
}
spring-boot-samples/spring-boot-sample-velocity/src/main/resources/application.properties
0 → 100644
View file @
3404850b
application.message
:
Hello, Andy
spring-boot-samples/spring-boot-sample-velocity/src/main/resources/templates/welcome.vm
0 → 100644
View file @
3404850b
From application: $time
Message: $message
\ No newline at end of file
spring-boot-samples/spring-boot-sample-velocity/src/test/java/sample/velocity/SampleVelocityApplicationTests.java
0 → 100644
View file @
3404850b
/*
* Copyright 2012-2014 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
sample
.
velocity
;
import
org.junit.ClassRule
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.springframework.boot.test.OutputCapture
;
import
org.springframework.boot.test.SpringApplicationConfiguration
;
import
org.springframework.test.context.junit4.SpringJUnit4ClassRunner
;
import
static
org
.
junit
.
Assert
.
assertTrue
;
/**
* Basic integration tests for Velocity application with no web layer.
*
* @author Dave Syer
*/
@RunWith
(
SpringJUnit4ClassRunner
.
class
)
@SpringApplicationConfiguration
(
classes
=
SampleVelocityApplication
.
class
)
public
class
SampleVelocityApplicationTests
{
@ClassRule
public
static
OutputCapture
output
=
new
OutputCapture
();
@Test
public
void
testVelocityTemplate
()
throws
Exception
{
String
result
=
SampleVelocityApplicationTests
.
output
.
toString
();
assertTrue
(
"Wrong output: "
+
result
,
result
.
contains
(
"Hello, Andy"
));
}
}
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