修改框架配置问题,修改profile中的test为stage,解决bootstrap.yml文件不读pom.xml文件统一配置问题
This commit is contained in:
@@ -97,15 +97,17 @@ swagger:
|
||||
password: admin
|
||||
# Druid连接配置
|
||||
# 框架配置
|
||||
frame:
|
||||
# 是否开启redis 用户登录,若开启此项,需要配置redis节点及相关配置,若不开启,需要注释掉redis相关配置信息
|
||||
isRedisLogin: true
|
||||
# 用户登陆超时设置,单位为小时,此值不能为0
|
||||
loginTimeout: 4
|
||||
# 是否开启controller日志监控
|
||||
showControllerLog: true
|
||||
# 是否开启多数据源
|
||||
multi-data-source: false
|
||||
# 框架配置
|
||||
hcframe:
|
||||
config:
|
||||
# 是否开启redis 用户登录,若开启此项,需要配置redis节点及相关配置,若不开启,需要注释掉redis相关配置信息
|
||||
isRedisLogin: true
|
||||
# 用户登陆超时设置,单位为小时,此值不能为0
|
||||
loginTimeout: 4
|
||||
# 是否开启controller日志监控
|
||||
showControllerLog: true
|
||||
# 是否开启多数据源
|
||||
multi-data-source: false
|
||||
druid:
|
||||
# Druid用户名
|
||||
username: test
|
||||
|
||||
@@ -6,10 +6,10 @@ import org.springframework.stereotype.Component;
|
||||
|
||||
@Data
|
||||
@Component
|
||||
@ConfigurationProperties(prefix = "frame")
|
||||
@ConfigurationProperties(prefix = "hcframe.config")
|
||||
public class FrameConfig {
|
||||
private Boolean isRedisLogin = false;
|
||||
private Integer loginTimeout = 4;
|
||||
private Boolean showControllerLog = true;
|
||||
private Boolean MultiDataSource = true;
|
||||
private Boolean multiDataSource = true;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.hcframe.base.common.config.annotation;
|
||||
|
||||
import org.springframework.context.annotation.Import;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
@Target(ElementType.TYPE)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface EnableHcFrame {
|
||||
}
|
||||
@@ -77,7 +77,7 @@
|
||||
</appender>
|
||||
|
||||
<!-- 系统模块日志级别控制 -->
|
||||
<logger name="com.common" level="info"/>
|
||||
<logger name="com.hcframe" level="info"/>
|
||||
<!-- Spring日志级别控制 -->
|
||||
<logger name="org.springframework" level="warn"/>
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.hcframe.config;
|
||||
|
||||
import net.unicon.cas.client.configuration.EnableCasClient;
|
||||
import net.unicon.cas.client.configuration.CasClientConfigurationProperties;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
||||
@@ -10,6 +10,7 @@ import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
|
||||
import org.springframework.cloud.openfeign.EnableFeignClients;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.context.annotation.EnableAspectJAutoProxy;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import springfox.documentation.swagger2.annotations.EnableSwagger2;
|
||||
|
||||
@SpringBootApplication(exclude = DataSourceAutoConfiguration.class)
|
||||
|
||||
@@ -15,21 +15,21 @@ spring:
|
||||
# 缓存设置
|
||||
cache:
|
||||
# redis缓存
|
||||
# type: redis
|
||||
# redis:
|
||||
# time-to-live: 1d
|
||||
# use-key-prefix: true
|
||||
# cache-null-values: true
|
||||
# key-prefix: cache.
|
||||
type: redis
|
||||
redis:
|
||||
time-to-live: 1d
|
||||
use-key-prefix: true
|
||||
cache-null-values: true
|
||||
key-prefix: cache.
|
||||
# ehcache缓存
|
||||
type: ehcache
|
||||
ehcache:
|
||||
config: classpath:ehcache.xml
|
||||
# type: ehcache
|
||||
# ehcache:
|
||||
# config: classpath:ehcache.xml
|
||||
redis:
|
||||
database: 0
|
||||
host: 192.168.4.119
|
||||
port: 6379
|
||||
password:
|
||||
database: @redis.database@
|
||||
host: @redis.host@
|
||||
port: @redis.port@
|
||||
password: @redis.password@
|
||||
lettuce:
|
||||
pool:
|
||||
# 连接池中的最大空闲连接 默认8
|
||||
@@ -78,14 +78,6 @@ mybatis:
|
||||
configuration:
|
||||
# 开启Sql日志记录
|
||||
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
|
||||
# 框架配置
|
||||
frame:
|
||||
# 是否开启redis 用户登录,若开启此项,需要配置redis节点及相关配置,若不开启,需要注释掉redis相关配置信息
|
||||
isRedisLogin: true
|
||||
# 用户登陆超时设置,单位为小时,此值不能为0
|
||||
loginTimeout: 4
|
||||
# 是否开启controller日志监控
|
||||
showControllerLog: true
|
||||
# swagger配置
|
||||
swagger:
|
||||
# 配置controller包路径
|
||||
@@ -125,7 +117,14 @@ hystrix:
|
||||
isolation:
|
||||
thread:
|
||||
timeoutInMilliseconds: 30000
|
||||
|
||||
|
||||
hcframe:
|
||||
config:
|
||||
# 是否开启redis 用户登录,若开启此项,需要配置redis节点及相关配置,若不开启,需要注释掉redis相关配置信息
|
||||
isRedisLogin: true
|
||||
# 用户登陆超时设置,单位为小时,此值不能为0
|
||||
loginTimeout: 4
|
||||
# 是否开启controller日志监控
|
||||
showControllerLog: true
|
||||
multi-data-source: true
|
||||
|
||||
|
||||
|
||||
@@ -81,10 +81,6 @@ mybatis:
|
||||
logging:
|
||||
level:
|
||||
com.common.common.dao : debug
|
||||
# 是否开启redis 用户登录,若开启此项,需要配置redis节点及相关配置,若不开启,需要注释掉redis相关配置信息
|
||||
isRedisLogin: false
|
||||
# 用户登陆超时设置,单位为小时,此值不能为0
|
||||
login-time-out: 4
|
||||
# swagger配置
|
||||
swagger:
|
||||
# 配置controller包路径
|
||||
@@ -106,6 +102,14 @@ druid:
|
||||
# Druid 拒绝访问的IP,默认不拒绝全部
|
||||
# deny: 10.0.0.2
|
||||
# 是否开启controller日志监控
|
||||
show-controller-log: false
|
||||
|
||||
# 框架配置
|
||||
hcframe:
|
||||
config:
|
||||
# 是否开启redis 用户登录,若开启此项,需要配置redis节点及相关配置,若不开启,需要注释掉redis相关配置信息
|
||||
isRedisLogin: true
|
||||
# 用户登陆超时设置,单位为小时,此值不能为0
|
||||
loginTimeout: 4
|
||||
# 是否开启controller日志监控
|
||||
showControllerLog: true
|
||||
multi-data-source: false
|
||||
|
||||
|
||||
@@ -60,14 +60,6 @@ eureka:
|
||||
service-url:
|
||||
# defaultZone: http://admin:123456@tomcat1:8080/eureka/
|
||||
defaultZone: http://admin:123456@192.168.4.119:8081/eureka/
|
||||
# 框架配置
|
||||
frame:
|
||||
# 是否开启redis 用户登录,若开启此项,需要配置redis节点及相关配置,若不开启,需要注释掉redis相关配置信息
|
||||
isRedisLogin: true
|
||||
# 用户登陆超时设置,单位为小时,此值不能为0
|
||||
loginTimeout: 4
|
||||
# 是否开启controller日志监控
|
||||
showControllerLog: true
|
||||
# swagger配置
|
||||
swagger:
|
||||
# 配置controller包路径
|
||||
|
||||
@@ -46,23 +46,6 @@ spring:
|
||||
filters: stat,slf4j
|
||||
# 通过connectProperties属性来打开mergeSql功能;慢SQL记录
|
||||
connectionProperties: druid.stat.mergeSql=true;druid.stat.slowSqlMillis=5000
|
||||
# 若不使用redis需要注释掉此类信息
|
||||
redis:
|
||||
database: 0
|
||||
host: 192.168.4.119
|
||||
port: 6379
|
||||
password:
|
||||
lettuce:
|
||||
pool:
|
||||
# 连接池中的最大空闲连接 默认8
|
||||
max-idle: 8
|
||||
# 连接池中的最小空闲连接 默认0
|
||||
min-idle: 0
|
||||
# 连接池最大连接数 默认8 ,负数表示没有限制
|
||||
max-active: 8
|
||||
# 连接池最大阻塞等待时间(使用负值表示没有限制) 默认-1
|
||||
max-wait: -1
|
||||
timeout: 30000
|
||||
eureka:
|
||||
client:
|
||||
service-url:
|
||||
|
||||
@@ -46,23 +46,6 @@ spring:
|
||||
filters: stat,slf4j
|
||||
# 通过connectProperties属性来打开mergeSql功能;慢SQL记录
|
||||
connectionProperties: druid.stat.mergeSql=true;druid.stat.slowSqlMillis=5000
|
||||
# 若不使用redis需要注释掉此类信息
|
||||
redis:
|
||||
database: 0
|
||||
host: 192.168.100.145
|
||||
port: 6379
|
||||
password: root
|
||||
lettuce:
|
||||
pool:
|
||||
# 连接池中的最大空闲连接 默认8
|
||||
max-idle: 8
|
||||
# 连接池中的最小空闲连接 默认0
|
||||
min-idle: 0
|
||||
# 连接池最大连接数 默认8 ,负数表示没有限制
|
||||
max-active: 8
|
||||
# 连接池最大阻塞等待时间(使用负值表示没有限制) 默认-1
|
||||
max-wait: -1
|
||||
timeout: 30000
|
||||
# 框架配置
|
||||
frame:
|
||||
# 是否开启redis 用户登录,若开启此项,需要配置redis节点及相关配置,若不开启,需要注释掉redis相关配置信息
|
||||
@@ -36,3 +36,11 @@ hcframe:
|
||||
logout-url: @cas.logout-url@
|
||||
cas-service-url: @cas.cas-service-url@
|
||||
client-context-path: @cas.client-context-path@
|
||||
config:
|
||||
# 是否开启redis 用户登录,若开启此项,需要配置redis节点及相关配置,若不开启,需要注释掉redis相关配置信息
|
||||
isRedisLogin: true
|
||||
# 用户登陆超时设置,单位为小时,此值不能为0
|
||||
loginTimeout: 4
|
||||
# 是否开启controller日志监控
|
||||
showControllerLog: true
|
||||
multi-data-source: false
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
<groupId>com.hcframe</groupId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<packaging>war</packaging>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>hcframe-user</artifactId>
|
||||
@@ -49,6 +50,7 @@
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<finalName>user</finalName>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.hcframe.user;
|
||||
|
||||
|
||||
import org.springframework.boot.builder.SpringApplicationBuilder;
|
||||
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
|
||||
|
||||
/**
|
||||
* @author lhc
|
||||
*/
|
||||
public class ServletInitializer extends SpringBootServletInitializer {
|
||||
|
||||
@Override
|
||||
protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
|
||||
return builder.sources(UserApplication.class);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.hcframe.user;
|
||||
|
||||
import net.unicon.cas.client.configuration.CasClientConfigurationProperties;
|
||||
import net.unicon.cas.client.configuration.EnableCasClient;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
@@ -9,6 +10,7 @@ import org.springframework.cache.annotation.EnableCaching;
|
||||
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.context.annotation.EnableAspectJAutoProxy;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import springfox.documentation.swagger2.annotations.EnableSwagger2;
|
||||
|
||||
import java.net.URLEncoder;
|
||||
@@ -20,6 +22,7 @@ import java.net.URLEncoder;
|
||||
@EnableCaching
|
||||
@ComponentScan(basePackages = {"com.hcframe.**"})
|
||||
@EnableDiscoveryClient
|
||||
@Import(CasClientConfigurationProperties.class)
|
||||
//@EnableCasClient
|
||||
public class UserApplication {
|
||||
public static void main(String[] args) {
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.hcframe.user.module.manage.controller;
|
||||
|
||||
import com.hcframe.base.common.ResultVO;
|
||||
import com.hcframe.redis.RedisUtil;
|
||||
import net.unicon.cas.client.configuration.CasClientConfigurationProperties;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.CookieValue;
|
||||
@@ -19,9 +20,18 @@ import java.net.URLDecoder;
|
||||
@RequestMapping("cas")
|
||||
public class CasController {
|
||||
|
||||
@Autowired
|
||||
final
|
||||
RedisUtil redisUtil;
|
||||
|
||||
final
|
||||
CasClientConfigurationProperties casClientConfigurationProperties;
|
||||
|
||||
public CasController(RedisUtil redisUtil, CasClientConfigurationProperties casClientConfigurationProperties) {
|
||||
this.redisUtil = redisUtil;
|
||||
this.casClientConfigurationProperties = casClientConfigurationProperties;
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("valid")
|
||||
public ResultVO<String> casValid(HttpServletResponse response, HttpServletRequest request,String webUrl) {
|
||||
String token = "";
|
||||
@@ -50,10 +60,12 @@ public class CasController {
|
||||
|
||||
@GetMapping("/logout")
|
||||
@ResponseBody
|
||||
public ResultVO<String> logout(HttpServletResponse response, @CookieValue("X-Access-Token") String token) {
|
||||
public ResultVO<String> logout(HttpServletRequest request, @CookieValue("X-Access-Token") String token) {
|
||||
Cookie cookie = new Cookie("X-Access-Token", null);
|
||||
cookie.setMaxAge(0);
|
||||
String headerToken = request.getHeader("X-Access-Token");
|
||||
redisUtil.hdel("session", token);
|
||||
return ResultVO.getSuccess("http://192.168.1.131:8080/cas/logout");
|
||||
redisUtil.hdel("session", headerToken);
|
||||
return ResultVO.getSuccess(casClientConfigurationProperties.getServerUrlPrefix()+"/cas/logout");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,13 +82,15 @@ mybatis:
|
||||
# 开启Sql日志记录
|
||||
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
|
||||
# 框架配置
|
||||
frame:
|
||||
# 是否开启redis 用户登录,若开启此项,需要配置redis节点及相关配置,若不开启,需要注释掉redis相关配置信息
|
||||
isRedisLogin: true
|
||||
# 用户登陆超时设置,单位为小时,此值不能为0
|
||||
loginTimeout: 4
|
||||
# 是否开启controller日志监控
|
||||
showControllerLog: true
|
||||
hcframe:
|
||||
config:
|
||||
# 是否开启redis 用户登录,若开启此项,需要配置redis节点及相关配置,若不开启,需要注释掉redis相关配置信息
|
||||
isRedisLogin: true
|
||||
# 用户登陆超时设置,单位为小时,此值不能为0
|
||||
loginTimeout: 4
|
||||
# 是否开启controller日志监控
|
||||
showControllerLog: true
|
||||
multi-data-source: false
|
||||
# swagger配置
|
||||
swagger:
|
||||
# 配置controller包路径
|
||||
|
||||
@@ -127,13 +127,13 @@
|
||||
<!--当前环境-->
|
||||
<profile.name>dev</profile.name>
|
||||
<!--Nacos配置中心地址-->
|
||||
<config.server-addr>192.168.1.131:8848</config.server-addr>
|
||||
<config.server-addr>192.168.100.98:8848</config.server-addr>
|
||||
<!--Nacos配置中心命名空间,用于支持多环境.这里必须使用ID,不能使用名称,默认为空-->
|
||||
<config.namespace>2e9f0148-751e-4da2-83ec-cb00ffe0d83a</config.namespace>
|
||||
<!--Nacos配置分组名称-->
|
||||
<config.group>DEFAULT_GROUP</config.group>
|
||||
<!-- Nacos服务发现地址-->
|
||||
<discovery.server-addr>192.168.1.131:8848</discovery.server-addr>
|
||||
<discovery.server-addr>192.168.100.98:8848</discovery.server-addr>
|
||||
<!-- redis 配置-->
|
||||
<redis.database>0</redis.database>
|
||||
<redis.host>192.168.4.119</redis.host>
|
||||
@@ -141,37 +141,38 @@
|
||||
<redis.password/>
|
||||
<!-- cas配置 -->
|
||||
<cas.client-context-path>/user/cas/valid</cas.client-context-path>
|
||||
<cas.cas-service-url>http://192.168.1.131:8080</cas.cas-service-url>
|
||||
<cas.cas-service-url>http://192.168.100.98:8080</cas.cas-service-url>
|
||||
<cas.cas-context-path>/cas</cas.cas-context-path>
|
||||
<cas.white-url>^.*(/logout?)$</cas.white-url>
|
||||
<cas.service-url>http://192.168.1.130:8084</cas.service-url>
|
||||
<cas.service-url>http://192.168.100.98:8084</cas.service-url>
|
||||
<cas.cookie-holder-pattern>com.hcframe.gateway.config.MyDataStorage</cas.cookie-holder-pattern>
|
||||
<cas.login-url>/login</cas.login-url>
|
||||
<cas.logout-url>/logout</cas.logout-url>
|
||||
</properties>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>test</id>
|
||||
<id>stage</id>
|
||||
<properties>
|
||||
<profile.name>test</profile.name>
|
||||
<profile.name>stage</profile.name>
|
||||
<!--Nacos配置中心地址-->
|
||||
<config.server-addr>192.168.1.131:8848</config.server-addr>
|
||||
<config.server-addr>192.168.100.98:8848</config.server-addr>
|
||||
<!--Nacos配置中心命名空间,用于支持多环境.这里必须使用ID,不能使用名称,默认为空-->
|
||||
<config.namespace>2e9f0148-751e-4da2-83ec-cb00ffe0d83a</config.namespace>
|
||||
<!--Nacos配置分组名称-->
|
||||
<config.group>DEFAULT_GROUP</config.group>
|
||||
<!--Nacos服务发现地址-->
|
||||
<discovery.server-addr>192.168.1.131:8848</discovery.server-addr>
|
||||
<!-- Nacos服务发现地址-->
|
||||
<discovery.server-addr>192.168.100.98:8848</discovery.server-addr>
|
||||
<!-- redis 配置-->
|
||||
<redis.database>0</redis.database>
|
||||
<redis.host>192.168.4.119</redis.host>
|
||||
<redis.port>6379</redis.port>
|
||||
<redis.password/>
|
||||
<!-- cas配置 -->
|
||||
<cas.enabled>true</cas.enabled>
|
||||
<cas.cas-service-url>http://192.168.1.131:8080</cas.cas-service-url>
|
||||
<cas.client-context-path>/user/cas/valid</cas.client-context-path>
|
||||
<cas.cas-service-url>http://192.168.100.98:8080</cas.cas-service-url>
|
||||
<cas.cas-context-path>/cas</cas.cas-context-path>
|
||||
<cas.white-url>^(.*(/logout?))|(/user/cas/url)$</cas.white-url>
|
||||
<cas.service-url>http://192.168.1.130:9527</cas.service-url>
|
||||
<cas.white-url>^.*(/logout?)$</cas.white-url>
|
||||
<cas.service-url>http://192.168.100.98:8084</cas.service-url>
|
||||
<cas.cookie-holder-pattern>com.hcframe.gateway.config.MyDataStorage</cas.cookie-holder-pattern>
|
||||
<cas.login-url>/login</cas.login-url>
|
||||
<cas.logout-url>/logout</cas.logout-url>
|
||||
@@ -203,6 +204,7 @@
|
||||
<cas.cookie-holder-pattern>com.hcframe.gateway.config.MyDataStorage</cas.cookie-holder-pattern>
|
||||
<cas.login-url>/login</cas.login-url>
|
||||
<cas.logout-url>/logout</cas.logout-url>
|
||||
<cas.client-context-path>/user/cas/valid</cas.client-context-path>
|
||||
</properties>
|
||||
</profile>
|
||||
</profiles>
|
||||
|
||||
Reference in New Issue
Block a user