Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
guns-vip
Overview
Overview
Details
Activity
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
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
chenjunxiong
guns-vip
Commits
ab03d056
Commit
ab03d056
authored
May 24, 2017
by
fsn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
重新整理beetl配置
parent
6e647ca5
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
122 additions
and
61 deletions
+122
-61
src/main/java/com/stylefeng/guns/config/properties/BeetlProperties.java
+67
-24
src/main/java/com/stylefeng/guns/config/web/BeetlConfig.java
+47
-0
src/main/java/com/stylefeng/guns/config/web/WebConfig.java
+0
-36
src/main/resources/application.yml
+8
-1
No files found.
src/main/java/com/stylefeng/guns/config/properties/BeetlProperties.java
View file @
ab03d056
package
com
.
stylefeng
.
guns
.
config
.
properties
;
package
com
.
stylefeng
.
guns
.
config
.
properties
;
import
com.stylefeng.guns.core.util.ToolUtil
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.boot.context.properties.ConfigurationProperties
;
import
org.springframework.context.annotation.Configuration
;
import
java.util.Properties
;
import
java.util.Properties
;
/**
/**
* beetl配置
* beetl配置
(如果需要配置别的配置可参照这个形式自己添加)
*
*
* @author fengshuonan
* @author fengshuonan
* @date 2017-05-2
2 18:45
* @date 2017-05-2
4 20:37
*/
*/
@Configuration
@ConfigurationProperties
(
prefix
=
BeetlProperties
.
BEETLCONF_PREFIX
)
public
class
BeetlProperties
{
public
class
BeetlProperties
{
private
static
BeetlProperties
beetlProperties
=
new
BeetlProperties
();
public
static
final
String
BEETLCONF_PREFIX
=
"beetl"
;
private
String
delimiterStatementStart
;
private
String
delimiterStatementEnd
;
private
String
resourceTagroot
;
private
String
resourceTagsuffix
;
private
Properties
properties
=
new
Properties
();
@Value
(
"${spring.mvc.view.prefix}"
)
private
String
prefix
;
private
BeetlProperties
(){
public
Properties
getProperties
(){
init
();
Properties
properties
=
new
Properties
();
if
(
ToolUtil
.
isNotEmpty
(
delimiterStatementStart
)){
if
(
delimiterStatementStart
.
startsWith
(
"\\"
)){
delimiterStatementStart
=
delimiterStatementStart
.
substring
(
1
);
}
properties
.
setProperty
(
"DELIMITER_STATEMENT_START"
,
delimiterStatementStart
);
}
if
(
ToolUtil
.
isNotEmpty
(
delimiterStatementEnd
)){
properties
.
setProperty
(
"DELIMITER_STATEMENT_END"
,
delimiterStatementEnd
);
}
else
{
properties
.
setProperty
(
"DELIMITER_STATEMENT_END"
,
"null"
);
}
if
(
ToolUtil
.
isNotEmpty
(
resourceTagroot
)){
properties
.
setProperty
(
"RESOURCE.tagRoot"
,
resourceTagroot
);
}
if
(
ToolUtil
.
isNotEmpty
(
resourceTagsuffix
)){
properties
.
setProperty
(
"RESOURCE.tagSuffix"
,
resourceTagsuffix
);
}
return
properties
;
}
}
public
void
init
()
{
public
String
getPrefix
()
{
//开始结束占位符
return
prefix
;
this
.
properties
.
setProperty
(
"DELIMITER_PLACEHOLDER_START"
,
"${"
);
}
this
.
properties
.
setProperty
(
"DELIMITER_PLACEHOLDER_END"
,
"}"
);
//开始结束标签
public
String
getDelimiterStatementStart
()
{
this
.
properties
.
setProperty
(
"DELIMITER_STATEMENT_START"
,
"@"
)
;
return
delimiterStatementStart
;
this
.
properties
.
setProperty
(
"DELIMITER_STATEMENT_END"
,
"null"
);
}
//classpath 根路径
public
void
setDelimiterStatementStart
(
String
delimiterStatementStart
)
{
this
.
properties
.
setProperty
(
"RESOURCE.root"
,
"/"
);
this
.
delimiterStatementStart
=
delimiterStatementStart
;
}
//是否检测文件变化
public
String
getDelimiterStatementEnd
()
{
this
.
properties
.
setProperty
(
"RESOURCE.autoCheck"
,
"true"
);
return
delimiterStatementEnd
;
}
//beetl HTMl标签
public
void
setDelimiterStatementEnd
(
String
delimiterStatementEnd
)
{
this
.
properties
.
setProperty
(
"HTML_TAG_FLAG"
,
"#"
);
this
.
delimiterStatementEnd
=
delimiterStatementEnd
;
}
public
String
getResourceTagroot
()
{
return
resourceTagroot
;
}
public
void
setResourceTagroot
(
String
resourceTagroot
)
{
this
.
resourceTagroot
=
resourceTagroot
;
}
//自定义标签文件Root目录和后缀
public
String
getResourceTagsuffix
()
{
this
.
properties
.
setProperty
(
"RESOURCE.tagRoot"
,
"common/tags"
);
return
resourceTagsuffix
;
this
.
properties
.
setProperty
(
"RESOURCE.tagSuffix"
,
"tag"
);
}
}
public
static
Properties
newInstance
()
{
public
void
setResourceTagsuffix
(
String
resourceTagsuffix
)
{
return
beetlProperties
.
properties
;
this
.
resourceTagsuffix
=
resourceTagsuffix
;
}
}
}
}
src/main/java/com/stylefeng/guns/config/web/BeetlConfig.java
0 → 100644
View file @
ab03d056
package
com
.
stylefeng
.
guns
.
config
.
web
;
import
com.stylefeng.guns.config.properties.BeetlProperties
;
import
com.stylefeng.guns.core.beetl.BeetlConfiguration
;
import
org.beetl.core.resource.ClasspathResourceLoader
;
import
org.beetl.ext.spring.BeetlSpringViewResolver
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.context.properties.ConfigurationProperties
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
/**
* web 配置类
*
* @author fengshuonan
* @date 2016年11月12日 下午5:03:32
*/
@Configuration
@ConfigurationProperties
(
prefix
=
"spring.mvc.view"
)
public
class
BeetlConfig
{
@Autowired
BeetlProperties
beetlProperties
;
/**
* beetl的配置
*/
@Bean
(
initMethod
=
"init"
)
public
BeetlConfiguration
beetlConfiguration
()
{
BeetlConfiguration
beetlConfiguration
=
new
BeetlConfiguration
();
beetlConfiguration
.
setResourceLoader
(
new
ClasspathResourceLoader
(
BeetlConfig
.
class
.
getClassLoader
(),
beetlProperties
.
getPrefix
()));
beetlConfiguration
.
setConfigProperties
(
beetlProperties
.
getProperties
());
return
beetlConfiguration
;
}
/**
* beetl的视图解析器
*/
@Bean
public
BeetlSpringViewResolver
beetlViewResolver
()
{
BeetlSpringViewResolver
beetlSpringViewResolver
=
new
BeetlSpringViewResolver
();
beetlSpringViewResolver
.
setConfig
(
beetlConfiguration
());
beetlSpringViewResolver
.
setContentType
(
"text/html;charset=UTF-8"
);
beetlSpringViewResolver
.
setOrder
(
0
);
return
beetlSpringViewResolver
;
}
}
src/main/java/com/stylefeng/guns/config/web/WebConfig.java
View file @
ab03d056
package
com
.
stylefeng
.
guns
.
config
.
web
;
package
com
.
stylefeng
.
guns
.
config
.
web
;
import
com.alibaba.druid.support.http.StatViewServlet
;
import
com.alibaba.druid.support.http.StatViewServlet
;
import
com.stylefeng.guns.config.properties.BeetlProperties
;
import
com.stylefeng.guns.core.beetl.BeetlConfiguration
;
import
com.stylefeng.guns.core.listener.ConfigListener
;
import
com.stylefeng.guns.core.listener.ConfigListener
;
import
com.stylefeng.guns.core.util.xss.XssFilter
;
import
com.stylefeng.guns.core.util.xss.XssFilter
;
import
org.beetl.core.resource.ClasspathResourceLoader
;
import
org.beetl.ext.spring.BeetlSpringViewResolver
;
import
org.springframework.boot.context.properties.ConfigurationProperties
;
import
org.springframework.boot.web.servlet.FilterRegistrationBean
;
import
org.springframework.boot.web.servlet.FilterRegistrationBean
;
import
org.springframework.boot.web.servlet.ServletListenerRegistrationBean
;
import
org.springframework.boot.web.servlet.ServletListenerRegistrationBean
;
import
org.springframework.boot.web.servlet.ServletRegistrationBean
;
import
org.springframework.boot.web.servlet.ServletRegistrationBean
;
...
@@ -22,35 +17,8 @@ import org.springframework.web.context.request.RequestContextListener;
...
@@ -22,35 +17,8 @@ import org.springframework.web.context.request.RequestContextListener;
* @date 2016年11月12日 下午5:03:32
* @date 2016年11月12日 下午5:03:32
*/
*/
@Configuration
@Configuration
@ConfigurationProperties
(
prefix
=
"spring.mvc.view"
)
public
class
WebConfig
{
public
class
WebConfig
{
//beetl模板所放的地方
private
String
prefix
;
/**
* beetl的配置
*/
@Bean
(
initMethod
=
"init"
)
public
BeetlConfiguration
beetlConfiguration
()
{
BeetlConfiguration
beetlConfiguration
=
new
BeetlConfiguration
();
beetlConfiguration
.
setResourceLoader
(
new
ClasspathResourceLoader
(
WebConfig
.
class
.
getClassLoader
(),
prefix
));
beetlConfiguration
.
setConfigProperties
(
BeetlProperties
.
newInstance
());
return
beetlConfiguration
;
}
/**
* beetl的视图解析器
*/
@Bean
public
BeetlSpringViewResolver
beetlViewResolver
()
{
BeetlSpringViewResolver
beetlSpringViewResolver
=
new
BeetlSpringViewResolver
();
beetlSpringViewResolver
.
setConfig
(
beetlConfiguration
());
beetlSpringViewResolver
.
setContentType
(
"text/html;charset=UTF-8"
);
beetlSpringViewResolver
.
setOrder
(
0
);
return
beetlSpringViewResolver
;
}
/**
/**
* druidServlet注册
* druidServlet注册
*/
*/
...
@@ -86,8 +54,4 @@ public class WebConfig {
...
@@ -86,8 +54,4 @@ public class WebConfig {
public
ServletListenerRegistrationBean
<
ConfigListener
>
configListenerRegistration
()
{
public
ServletListenerRegistrationBean
<
ConfigListener
>
configListenerRegistration
()
{
return
new
ServletListenerRegistrationBean
<>(
new
ConfigListener
());
return
new
ServletListenerRegistrationBean
<>(
new
ConfigListener
());
}
}
public
void
setPrefix
(
String
prefix
)
{
this
.
prefix
=
prefix
;
}
}
}
src/main/resources/application.yml
View file @
ab03d056
...
@@ -2,11 +2,18 @@
...
@@ -2,11 +2,18 @@
guns
:
guns
:
kaptcha-open
:
false
#是否开启登录时验证码 (true/false)
kaptcha-open
:
false
#是否开启登录时验证码 (true/false)
################### 项目启动端口 ###################
################### 项目启动端口 ###################
server
:
server
:
port
:
80
port
:
80
################### beetl配置 ###################
beetl
:
delimiter-statement-start
:
\@
#开始结束标签(yaml不允许@开头)
delimiter-statement-end
:
null
resource-tagroot
:
common/tags
#自定义标签文件Root目录和后缀
resource-tagsuffix
:
tag
################### spring配置 ###################
################### spring配置 ###################
spring
:
spring
:
profiles
:
profiles
:
...
...
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