Skip to content

Commit 800f6ce

Browse files
committed
ApiBoot Logging Admin Sample示例
1 parent 2b174c8 commit 800f6ce

File tree

5 files changed

+219
-0
lines changed

5 files changed

+219
-0
lines changed
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
~ Copyright [2019] [恒宇少年 - 于起宇]
4+
~
5+
~ Licensed under the Apache License, Version 2.0 (the "License");
6+
~ you may not use this file except in compliance with the License.
7+
~ You may obtain a copy of the License at
8+
~
9+
~ http://www.apache.org/licenses/LICENSE-2.0
10+
~
11+
~ Unless required by applicable law or agreed to in writing, software
12+
~ distributed under the License is distributed on an "AS IS" BASIS,
13+
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
~ See the License for the specific language governing permissions and
15+
~ limitations under the License.
16+
~
17+
-->
18+
19+
<project xmlns="http://maven.apache.org/POM/4.0.0"
20+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
21+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
22+
<parent>
23+
<artifactId>api-boot-samples</artifactId>
24+
<groupId>org.minbox.framework</groupId>
25+
<version>2.1.2-SNAPSHOT</version>
26+
</parent>
27+
<modelVersion>4.0.0</modelVersion>
28+
29+
<properties>
30+
<spring.cloud.version>Greenwich.RELEASE</spring.cloud.version>
31+
</properties>
32+
<artifactId>api-boot-sample-logging-admin</artifactId>
33+
<dependencies>
34+
35+
<dependency>
36+
<groupId>org.springframework.boot</groupId>
37+
<artifactId>spring-boot-starter-web</artifactId>
38+
</dependency>
39+
<!--ApiBoot Logging Admin-->
40+
<dependency>
41+
<groupId>org.minbox.framework</groupId>
42+
<artifactId>api-boot-starter-logging-admin</artifactId>
43+
</dependency>
44+
<dependency>
45+
<groupId>org.springframework.boot</groupId>
46+
<artifactId>spring-boot-starter-security</artifactId>
47+
</dependency>
48+
<!--<dependency>
49+
<groupId>org.springframework.cloud</groupId>
50+
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
51+
</dependency>-->
52+
<dependency>
53+
<groupId>org.minbox.framework</groupId>
54+
<artifactId>api-boot-starter-mybatis-enhance</artifactId>
55+
</dependency>
56+
<dependency>
57+
<groupId>mysql</groupId>
58+
<artifactId>mysql-connector-java</artifactId>
59+
</dependency>
60+
<dependency>
61+
<groupId>com.zaxxer</groupId>
62+
<artifactId>HikariCP</artifactId>
63+
</dependency>
64+
65+
</dependencies>
66+
<dependencyManagement>
67+
<dependencies>
68+
<dependency>
69+
<groupId>org.minbox.framework</groupId>
70+
<artifactId>api-boot-dependencies</artifactId>
71+
<version>2.1.2-SNAPSHOT</version>
72+
<type>pom</type>
73+
<scope>import</scope>
74+
</dependency>
75+
<!--SpringCloud版本依赖-->
76+
<dependency>
77+
<groupId>org.springframework.cloud</groupId>
78+
<artifactId>spring-cloud-dependencies</artifactId>
79+
<version>${spring.cloud.version}</version>
80+
<scope>import</scope>
81+
<type>pom</type>
82+
</dependency>
83+
</dependencies>
84+
</dependencyManagement>
85+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
* Copyright [2019] [恒宇少年 - 于起宇]
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*
16+
*/
17+
18+
package org.minbox.framework.api.boot.sample.logging.admin;
19+
20+
import org.slf4j.Logger;
21+
import org.slf4j.LoggerFactory;
22+
import org.springframework.boot.SpringApplication;
23+
import org.springframework.boot.autoconfigure.SpringBootApplication;
24+
25+
/**
26+
* @author:恒宇少年 - 于起宇
27+
* <p>
28+
* DateTime:2019-07-19 17:55
29+
* Blog:http://blog.yuqiyu.com
30+
* WebSite:http://www.jianshu.com/u/092df3f77bca
31+
* Gitee:https://gitee.com/hengboy
32+
* GitHub:https://github.com/hengboy
33+
*/
34+
@SpringBootApplication
35+
public class ApiBootLoggingAdminApplication{
36+
/**
37+
* logger instance
38+
*/
39+
static Logger logger = LoggerFactory.getLogger(ApiBootLoggingAdminApplication.class);
40+
41+
public static void main(String[] args) {
42+
SpringApplication.run(ApiBootLoggingAdminApplication.class, args);
43+
logger.info("{}服务启动成功.", "");
44+
}
45+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/*
2+
* Copyright [2019] [恒宇少年 - 于起宇]
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*
16+
*/
17+
18+
package org.minbox.framework.api.boot.sample.logging.admin;
19+
20+
import org.springframework.context.annotation.Configuration;
21+
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
22+
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
23+
24+
/**
25+
* @author:恒宇少年 - 于起宇
26+
* <p>
27+
* DateTime:2019-07-19 18:28
28+
* Blog:http://blog.yuqiyu.com
29+
* WebSite:http://www.jianshu.com/u/092df3f77bca
30+
* Gitee:https://gitee.com/hengboy
31+
* GitHub:https://github.com/hengboy
32+
*/
33+
@Configuration
34+
public class SecurityConfig extends WebSecurityConfigurerAdapter {
35+
/**
36+
* 配置安全信息
37+
* - 禁用csrf攻击功能
38+
* - 开启所有请求需要验证并且使用http basic进行认证
39+
*
40+
* @param http
41+
* @throws Exception
42+
*/
43+
@Override
44+
protected void configure(HttpSecurity http) throws Exception {
45+
46+
http.csrf()
47+
.disable()
48+
.authorizeRequests()
49+
.anyRequest().authenticated()
50+
.and()
51+
.httpBasic();
52+
}
53+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Eureka Config
2+
eureka:
3+
client:
4+
service-url:
5+
defaultZone: http://service:nodev2@127.0.0.1:9090/eureka/
6+
instance:
7+
prefer-ip-address: true
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
spring:
2+
application:
3+
name: api-boot-sample-logging-admin
4+
security:
5+
user:
6+
name: user
7+
password: 123456
8+
datasource:
9+
driver-class-name: com.mysql.cj.jdbc.Driver
10+
type: com.zaxxer.hikari.HikariDataSource
11+
username: root
12+
password: 123456
13+
url: jdbc:mysql://localhost:3306/test
14+
logging:
15+
level:
16+
org.minbox.framework.api.boot.plugin.logging: debug
17+
18+
server:
19+
port: 9090
20+
21+
22+
api:
23+
boot:
24+
logging:
25+
admin:
26+
# 显示上报日志
27+
show-console-report-log: true
28+
# 格式化上报日志
29+
format-console-log-json: true

0 commit comments

Comments
 (0)