您的位置:首页 > 其它

CAS之5.2x版本之通过yml的方式配置cas-yellowcong

2018-02-05 16:46 489 查看
cas5.2版本是基于springboot的,一般情况下,我们是使用的application.properties 配置文件,但是有一天,有人说我希望使用application.yml 的文件,不喜欢用properties这种方式,其实也是可以实现的,我采取的策略是,先放置一个空的application.properties文件在工程目录中,然后正常配置application.yml文件。

项目地址

https://gitee.com/yellowcong/springboot_cas/tree/master/cas-server-yml


目录结构

主要是通过让application.properties空文件,替换掉默认war包的配置,然后读取完application.properties后,再读取yml文件,这样就完美的解决了通过yml启动cas了。



配置cas

配置application.properties

用一个空的目录,来替换掉war包目录下的默认配置

##
# CAS Server Context Configuration
#
#设定项目的目录 / 表示根目录


配置application.yml

推荐大家去直接使用工具将properites相互转化,自己动手写太慢了。

properties转化为yml的网站:https://www.bejson.com/devtools/properties2yaml/

---
spring:
cloud:
bus:
enabled: false
aop:
proxy-target-class: true
auto: true
http:
encoding:
charset: UTF-8
force: true
enabled: true
thymeleaf:
mode: HTML
cache: false
encoding: UTF-8
# 服务器配置
server:
connection-timeout: 20000
#项目根目录配置
context-path: /
tomcat:
basedir: build/tomcat
remote-ip-header: X-FORWARDED-FOR
uri-encoding: UTF-8
protocol-header: X-Forwarded-Proto
protocol-header-https-value: https
port-header: X-Forwarded-Port
max-threads: 10
max-http-post-size: 2097152
accesslog:
pattern: '%t %a \%r\ %s (%D ms)'
suffix: .log
enabled: true
#端口陪孩子
port: 9000
max-http-header-size: 2097152
session:
tracking-modes: COOKIE
cookie:
http-only: true
timeout: 300
context-parameters:
isLog4jAutoInitializationDisabled: true
compression:
mime-types: application/javascript,application/json,application/xml,text/html,text/xml,text/plain
enabled: true
error:
include-stacktrace: ALWAYS
#证书配置
ssl:
keyAlias: tomcat
key-store: classpath:tomcat.keystore
key-store-password: yellowcong
enabled: true
use-forward-headers: true
security:
basic:
path: /status/**
authorize-mode: role
enabled: false
endpoints:
restart:
enabled: false
sensitive: true
shutdown:
enabled: false
enabled: false
cas:
tgc:
secure: false
logout:
followServiceRedirects: true
serviceRegistry:
initFromJson: true
ticket:
tgt:
rememberMe:
timeToKillInSeconds: 3600
enabled: true
warningCookie:
secure: false
authn:
accept:
#静态测试用户
users: yellowcong::yellowcong
management:
security:
sessions: if_required
roles: ACTUATOR,ADMIN
enabled: true
context-path: /status
add-application-context-header: false


启动服务

#直接启动,不debug了
build.cmd run




访问测试

服务访问正常



编译后的目录

我门可以看到编译后的cas目录,没有默认的配置,都被用户的配置替换了。



常见问题

yml文件报错

报错的原因是%是特殊符号,表示是命令,需要加上单引号,表示是字符串



加上单引号后,就不抱错了。

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: