添加日志 2021年11月17日15:50:29
parent
c6ae35354d
commit
33be0d7c00
|
|
@ -57,6 +57,7 @@ mapper:
|
||||||
mystyle:
|
mystyle:
|
||||||
security:
|
security:
|
||||||
open-api:
|
open-api:
|
||||||
|
- /
|
||||||
- /login
|
- /login
|
||||||
- /favicon.ico # 开放FAVICON
|
- /favicon.ico # 开放FAVICON
|
||||||
- /system/**
|
- /system/**
|
||||||
|
|
@ -76,6 +77,9 @@ verification-code:
|
||||||
type: mysql
|
type: mysql
|
||||||
expiration-time: 300
|
expiration-time: 300
|
||||||
redis-key: redis-29b9f4ddcf8072d2f856a67f76957821
|
redis-key: redis-29b9f4ddcf8072d2f856a67f76957821
|
||||||
|
logging:
|
||||||
|
file:
|
||||||
|
name: ./logs/mystyle-cloud-admin-manager.log
|
||||||
management:
|
management:
|
||||||
endpoints:
|
endpoints:
|
||||||
web:
|
web:
|
||||||
|
|
@ -84,4 +88,9 @@ management:
|
||||||
endpoint:
|
endpoint:
|
||||||
health:
|
health:
|
||||||
show-details: ALWAYS
|
show-details: ALWAYS
|
||||||
enabled: true
|
enabled: true
|
||||||
|
info:
|
||||||
|
version: 1.0
|
||||||
|
name: mystyle-cloud-admin-manager
|
||||||
|
author: zhangmeng
|
||||||
|
blog: 47.104.229.92:3000
|
||||||
|
|
@ -77,5 +77,12 @@
|
||||||
<version>2.2.4.RELEASE</version>
|
<version>2.2.4.RELEASE</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!-- https://mvnrepository.com/artifact/de.codecentric/spring-boot-admin-server-ui -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>de.codecentric</groupId>
|
||||||
|
<artifactId>spring-boot-admin-server-ui</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
|
|
@ -66,4 +66,8 @@ management:
|
||||||
endpoint:
|
endpoint:
|
||||||
health:
|
health:
|
||||||
show-details: ALWAYS
|
show-details: ALWAYS
|
||||||
enabled: true
|
enabled: true
|
||||||
|
logging:
|
||||||
|
file:
|
||||||
|
name: ./logs/mystyle-cloud-blog.log
|
||||||
|
level: debug
|
||||||
|
|
@ -23,4 +23,7 @@ canal:
|
||||||
host: 127.0.0.1
|
host: 127.0.0.1
|
||||||
port: 11111
|
port: 11111
|
||||||
userName: canal
|
userName: canal
|
||||||
password: canal
|
password: canal
|
||||||
|
logging:
|
||||||
|
file:
|
||||||
|
name: ./logs/mystyle-cloud-canal.log
|
||||||
|
|
@ -68,4 +68,7 @@ management:
|
||||||
endpoint:
|
endpoint:
|
||||||
health:
|
health:
|
||||||
show-details: ALWAYS
|
show-details: ALWAYS
|
||||||
enabled: true
|
enabled: true
|
||||||
|
logging:
|
||||||
|
file:
|
||||||
|
name: ./logs/mystyle-cloud-fiction.log
|
||||||
|
|
@ -77,4 +77,7 @@ management:
|
||||||
endpoint:
|
endpoint:
|
||||||
health:
|
health:
|
||||||
show-details: ALWAYS
|
show-details: ALWAYS
|
||||||
enabled: true
|
enabled: true
|
||||||
|
logging:
|
||||||
|
file:
|
||||||
|
name: ./logs/mystyle-cloud-file.log
|
||||||
|
|
@ -93,3 +93,6 @@ management:
|
||||||
health:
|
health:
|
||||||
show-details: ALWAYS
|
show-details: ALWAYS
|
||||||
enabled: true
|
enabled: true
|
||||||
|
logging:
|
||||||
|
file:
|
||||||
|
name: ./logs/mystyle-cloud-gateway.log
|
||||||
|
|
@ -72,4 +72,7 @@ management:
|
||||||
endpoint:
|
endpoint:
|
||||||
health:
|
health:
|
||||||
show-details: ALWAYS
|
show-details: ALWAYS
|
||||||
enabled: true
|
enabled: true
|
||||||
|
logging:
|
||||||
|
file:
|
||||||
|
name: ./logs/mystyle-cloud-mail.log
|
||||||
|
|
@ -10,12 +10,25 @@
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
<artifactId>mystyle-cloud-mq</artifactId>
|
<artifactId>mystyle-cloud-mq</artifactId>
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<configuration>
|
||||||
|
<source>8</source>
|
||||||
|
<target>8</target>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>com.zhangmeng</groupId>
|
||||||
<artifactId>spring-boot-starter-web</artifactId>
|
<artifactId>mystyle-cloud-api</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,92 @@
|
||||||
|
package com.zhangmeng.mq.config;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.core.io.ClassPathResource;
|
||||||
|
import org.springframework.core.io.Resource;
|
||||||
|
import org.springframework.http.HttpMethod;
|
||||||
|
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
|
||||||
|
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
||||||
|
import org.springframework.security.oauth2.config.annotation.web.configuration.EnableResourceServer;
|
||||||
|
import org.springframework.security.oauth2.config.annotation.web.configuration.ResourceServerConfigurerAdapter;
|
||||||
|
import org.springframework.security.oauth2.provider.token.TokenStore;
|
||||||
|
import org.springframework.security.oauth2.provider.token.store.JwtAccessTokenConverter;
|
||||||
|
import org.springframework.security.oauth2.provider.token.store.JwtTokenStore;
|
||||||
|
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author 转身的背影在心底里沉沦
|
||||||
|
* @date 2021年9月14日16:45:29
|
||||||
|
* @version 1.0
|
||||||
|
*/
|
||||||
|
@Configuration
|
||||||
|
@EnableResourceServer
|
||||||
|
@EnableGlobalMethodSecurity(prePostEnabled = true, securedEnabled = true)// 激活方法上的PreAuthorize注解
|
||||||
|
public class ResourceServerConfig extends ResourceServerConfigurerAdapter {
|
||||||
|
|
||||||
|
// 公钥
|
||||||
|
private static final String PUBLIC_KEY = "public.key";
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SecurityProperty securityProperty;
|
||||||
|
|
||||||
|
/***
|
||||||
|
* 定义JwtTokenStore
|
||||||
|
* @param jwtAccessTokenConverter
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Bean
|
||||||
|
public TokenStore tokenStore(JwtAccessTokenConverter jwtAccessTokenConverter) {
|
||||||
|
return new JwtTokenStore(jwtAccessTokenConverter);
|
||||||
|
}
|
||||||
|
|
||||||
|
/***
|
||||||
|
* 定义JJwtAccessTokenConverter
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Bean
|
||||||
|
public JwtAccessTokenConverter jwtAccessTokenConverter() {
|
||||||
|
JwtAccessTokenConverter converter = new JwtAccessTokenConverter();
|
||||||
|
converter.setVerifierKey(getPubKey()); //秘钥的一部分
|
||||||
|
return converter;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 获取非对称加密公钥 Key
|
||||||
|
* @return 公钥 Key
|
||||||
|
*/
|
||||||
|
private String getPubKey() {
|
||||||
|
Resource resource = new ClassPathResource(PUBLIC_KEY);
|
||||||
|
try {
|
||||||
|
InputStreamReader inputStreamReader = new InputStreamReader(resource.getInputStream());
|
||||||
|
BufferedReader br = new BufferedReader(inputStreamReader);
|
||||||
|
return br.lines().collect(Collectors.joining("\n"));
|
||||||
|
} catch (IOException ioe) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/***
|
||||||
|
* SpringSecurity
|
||||||
|
* Http安全配置,对每个到达系统的http请求链接进行校验
|
||||||
|
* @param http
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void configure(HttpSecurity http) throws Exception {
|
||||||
|
|
||||||
|
http.headers().frameOptions().disable();
|
||||||
|
|
||||||
|
// 所有请求必须认证通过
|
||||||
|
http.authorizeRequests()
|
||||||
|
// 跨域预检请求
|
||||||
|
.antMatchers(HttpMethod.OPTIONS, "/**").permitAll()
|
||||||
|
.antMatchers(securityProperty.getOpenApi()).permitAll()
|
||||||
|
.anyRequest().
|
||||||
|
authenticated(); // 其他地址需要认证授权
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,79 @@
|
||||||
|
package com.zhangmeng.mq.config;
|
||||||
|
|
||||||
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author 转身的背影在心底里沉沦
|
||||||
|
* @date 2021年9月14日16:50:47
|
||||||
|
* @version 1.0
|
||||||
|
* */
|
||||||
|
@Configuration
|
||||||
|
@ConfigurationProperties("mystyle.security")
|
||||||
|
public class SecurityProperty {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 超级管理员不认证
|
||||||
|
* */
|
||||||
|
private boolean superAuthOpen;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 不验证权限用户名
|
||||||
|
* */
|
||||||
|
private String superAdmin;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 记住密码标识
|
||||||
|
* */
|
||||||
|
private String rememberKey;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 开放接口列表
|
||||||
|
* */
|
||||||
|
private String[] openApi;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否允许多账号在线
|
||||||
|
* */
|
||||||
|
private Integer maximum = 1;
|
||||||
|
|
||||||
|
public boolean isSuperAuthOpen() {
|
||||||
|
return superAuthOpen;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSuperAuthOpen(boolean superAuthOpen) {
|
||||||
|
this.superAuthOpen = superAuthOpen;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSuperAdmin() {
|
||||||
|
return superAdmin;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSuperAdmin(String superAdmin) {
|
||||||
|
this.superAdmin = superAdmin;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getRememberKey() {
|
||||||
|
return rememberKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRememberKey(String rememberKey) {
|
||||||
|
this.rememberKey = rememberKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String[] getOpenApi() {
|
||||||
|
return openApi;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOpenApi(String[] openApi) {
|
||||||
|
this.openApi = openApi;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getMaximum() {
|
||||||
|
return maximum;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMaximum(Integer maximum) {
|
||||||
|
this.maximum = maximum;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,59 @@
|
||||||
|
package com.zhangmeng.mq.controller;
|
||||||
|
|
||||||
|
import com.zhangmeng.model.vo.Result;
|
||||||
|
import org.springframework.amqp.core.BindingBuilder;
|
||||||
|
import org.springframework.amqp.core.FanoutExchange;
|
||||||
|
import org.springframework.amqp.core.Queue;
|
||||||
|
import org.springframework.amqp.rabbit.core.RabbitAdmin;
|
||||||
|
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.util.StringUtils;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/mq")
|
||||||
|
public class MqController {
|
||||||
|
|
||||||
|
// @Autowired
|
||||||
|
// private RabbitAdmin rabbitAdmin;
|
||||||
|
//
|
||||||
|
// private RabbitTemplate rabbitTemplate;
|
||||||
|
//
|
||||||
|
// @PostMapping("/sendMessage")
|
||||||
|
// public Result sendMessage(String queueName ,String message){
|
||||||
|
//
|
||||||
|
// createMQIfNotExist(queueName,queueName);
|
||||||
|
// return null;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// private void createMQIfNotExist(String queueName ,String exchangeName) {
|
||||||
|
// //判断队列是否存在
|
||||||
|
// Properties properties = rabbitAdmin.getQueueProperties(queueName);
|
||||||
|
// if(properties == null){
|
||||||
|
// Queue queue = new Queue(queueName, true, false, false, null);
|
||||||
|
// FanoutExchange fanoutExchange = new FanoutExchange(exchangeName);
|
||||||
|
// rabbitAdmin.declareQueue(queue);
|
||||||
|
// rabbitAdmin.declareExchange(fanoutExchange);
|
||||||
|
// rabbitAdmin.declareBinding(BindingBuilder.bind(queue).to(fanoutExchange));
|
||||||
|
//
|
||||||
|
// String res = callAddNewListener(queueName);
|
||||||
|
// if(!StringUtils.isEmpty(res)){
|
||||||
|
// System.out.println("-->>调用创建新的 listener feign 失败");
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// private String callAddNewListener(String queueName){
|
||||||
|
// return null;
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,4 @@
|
||||||
|
package com.zhangmeng.mq.service;
|
||||||
|
|
||||||
|
public interface MqService {
|
||||||
|
}
|
||||||
|
|
@ -3,6 +3,11 @@ server:
|
||||||
spring:
|
spring:
|
||||||
application:
|
application:
|
||||||
name: mystyle-cloud-mq
|
name: mystyle-cloud-mq
|
||||||
|
rabbitmq:
|
||||||
|
host: localhost
|
||||||
|
port: 5672
|
||||||
|
username: guest
|
||||||
|
password: guest
|
||||||
zipkin:
|
zipkin:
|
||||||
sender:
|
sender:
|
||||||
type: web
|
type: web
|
||||||
|
|
|
||||||
|
|
@ -70,4 +70,7 @@ management:
|
||||||
endpoint:
|
endpoint:
|
||||||
health:
|
health:
|
||||||
show-details: ALWAYS
|
show-details: ALWAYS
|
||||||
enabled: true
|
enabled: true
|
||||||
|
logging:
|
||||||
|
file:
|
||||||
|
name: ./logs/mystyle-cloud-oauth.log
|
||||||
|
|
@ -10,6 +10,18 @@
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
<artifactId>mystyle-cloud-quartz</artifactId>
|
<artifactId>mystyle-cloud-quartz</artifactId>
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<configuration>
|
||||||
|
<source>8</source>
|
||||||
|
<target>8</target>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|
|
||||||
|
|
@ -80,3 +80,6 @@ management:
|
||||||
health:
|
health:
|
||||||
show-details: ALWAYS
|
show-details: ALWAYS
|
||||||
enabled: true
|
enabled: true
|
||||||
|
logging:
|
||||||
|
file:
|
||||||
|
name: ./logs/mystyle-cloud-quartz.log
|
||||||
|
|
|
||||||
8
pom.xml
8
pom.xml
|
|
@ -279,6 +279,14 @@
|
||||||
<artifactId>spring-boot-admin-starter-client</artifactId>
|
<artifactId>spring-boot-admin-starter-client</artifactId>
|
||||||
<version>2.5.4</version>
|
<version>2.5.4</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!-- https://mvnrepository.com/artifact/de.codecentric/spring-boot-admin-server-ui -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>de.codecentric</groupId>
|
||||||
|
<artifactId>spring-boot-admin-server-ui</artifactId>
|
||||||
|
<version>2.5.4</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</dependencyManagement>
|
</dependencyManagement>
|
||||||
</project>
|
</project>
|
||||||
Loading…
Reference in New Issue