fanxw 1 年之前
父節點
當前提交
f2d7722633
共有 3 個文件被更改,包括 200 次插入160 次删除
  1. 162 158
      pom.xml
  2. 24 0
      src/main/java/com/chinaitop/WebSecurityConfig.java
  3. 14 2
      src/main/resources/application.yml

+ 162 - 158
pom.xml

@@ -1,168 +1,172 @@
1 1
 <?xml version="1.0" encoding="UTF-8"?>
2 2
 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3
-         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
4
-    <modelVersion>4.0.0</modelVersion>
5
-    <parent>
6
-        <groupId>org.springframework.boot</groupId>
7
-        <artifactId>spring-boot-starter-parent</artifactId>
8
-        <version>2.0.4.RELEASE</version>
9
-        <relativePath/> <!-- lookup parent from repository -->
10
-    </parent>
11
-    <groupId>com.chinaitop</groupId>
12
-    <artifactId>depot-api</artifactId>
13
-    <version>0.0.1</version>
14
-    <name>depot-api</name>
15
-    <packaging>jar</packaging>
16
-    <description>DepotApi project for Spring Boot for depot service</description>
3
+	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
4
+	<modelVersion>4.0.0</modelVersion>
5
+	<parent>
6
+		<groupId>org.springframework.boot</groupId>
7
+		<artifactId>spring-boot-starter-parent</artifactId>
8
+		<version>2.0.4.RELEASE</version>
9
+		<relativePath /> <!-- lookup parent from repository -->
10
+	</parent>
11
+	<groupId>com.chinaitop</groupId>
12
+	<artifactId>depot-api</artifactId>
13
+	<version>0.0.1</version>
14
+	<name>depot-api</name>
15
+	<packaging>jar</packaging>
16
+	<description>DepotApi project for Spring Boot for depot service</description>
17 17
 
18
-    <properties>
19
-        <java.version>1.8</java.version>
20
-        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
21
-        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
22
-        <spring-cloud.version>Finchley.RELEASE</spring-cloud.version>
23
-    </properties>
18
+	<properties>
19
+		<java.version>1.8</java.version>
20
+		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
21
+		<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
22
+		<spring-cloud.version>Finchley.RELEASE</spring-cloud.version>
23
+	</properties>
24 24
 
25
-    <dependencies>
26
-        <dependency>
27
-            <groupId>org.springframework.boot</groupId>
28
-            <artifactId>spring-boot-starter-web</artifactId>
29
-        </dependency>
30
-        <dependency>
31
-            <groupId>org.springframework.cloud</groupId>
32
-            <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
33
-        </dependency>
34
-        <dependency>
35
-            <groupId>org.springframework.cloud</groupId>
36
-            <artifactId>spring-cloud-starter-openfeign</artifactId>
37
-        </dependency>
38
-        <!-- utils -->
39
-        <!-- https://mvnrepository.com/artifact/com.alibaba/fastjson -->
40
-        <dependency>
41
-            <groupId>com.alibaba</groupId>
42
-            <artifactId>fastjson</artifactId>
43
-            <version>1.2.75</version>
44
-        </dependency>
45
-        <dependency>
46
-            <groupId>org.springframework.boot</groupId>
47
-            <artifactId>spring-boot-starter-test</artifactId>
48
-            <scope>test</scope>
49
-            <exclusions>
50
-                <exclusion>
51
-                    <groupId>org.junit.vintage</groupId>
52
-                    <artifactId>junit-vintage-engine</artifactId>
53
-                </exclusion>
54
-            </exclusions>
55
-        </dependency>
56
-        <!--mysql-->
57
-        <dependency>
58
-            <groupId>mysql</groupId>
59
-            <artifactId>mysql-connector-java</artifactId>
60
-        </dependency>
61
-        <!--代码生成-->
62
-        <dependency>
63
-            <groupId>com.baomidou</groupId>
64
-            <artifactId>mybatis-plus-generator</artifactId>
65
-            <version>3.2.0</version>
66
-        </dependency>
67
-        <dependency>
68
-            <groupId>org.apache.velocity</groupId>
69
-            <artifactId>velocity-engine-core</artifactId>
70
-            <version>2.1</version>
71
-        </dependency>
72
-        <dependency>
73
-            <groupId>org.freemarker</groupId>
74
-            <artifactId>freemarker</artifactId>
75
-            <version>2.3.29</version>
76
-        </dependency>
77
-        <dependency>
78
-            <groupId>org.projectlombok</groupId>
79
-            <artifactId>lombok</artifactId>
80
-            <optional>true</optional>
81
-        </dependency>
82
-        <dependency>
83
-            <groupId>org.springframework.boot</groupId>
84
-            <artifactId>spring-boot-starter</artifactId>
85
-        </dependency>
86
-        <dependency>
87
-            <groupId>com.baomidou</groupId>
88
-            <artifactId>mybatis-plus-boot-starter</artifactId>
89
-            <version>3.2.0</version>
90
-        </dependency>
91
-        <dependency>
92
-            <groupId>com.ibeetl</groupId>
93
-            <artifactId>beetl</artifactId>
94
-            <version>3.0.13.RELEASE</version>
95
-        </dependency>
25
+	<dependencies>
26
+		<dependency>
27
+			<groupId>org.springframework.boot</groupId>
28
+			<artifactId>spring-boot-starter-web</artifactId>
29
+		</dependency>
30
+		<dependency>
31
+			<groupId>org.springframework.cloud</groupId>
32
+			<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
33
+		</dependency>
34
+		<dependency>
35
+			<groupId>org.springframework.cloud</groupId>
36
+			<artifactId>spring-cloud-starter-openfeign</artifactId>
37
+		</dependency>
38
+		<dependency>  
39
+		    <groupId>org.springframework.boot</groupId>  
40
+		    <artifactId>spring-boot-starter-security</artifactId>  
41
+		</dependency>
42
+		<!-- utils -->
43
+		<!-- https://mvnrepository.com/artifact/com.alibaba/fastjson -->
44
+		<dependency>
45
+			<groupId>com.alibaba</groupId>
46
+			<artifactId>fastjson</artifactId>
47
+			<version>1.2.75</version>
48
+		</dependency>
49
+		<dependency>
50
+			<groupId>org.springframework.boot</groupId>
51
+			<artifactId>spring-boot-starter-test</artifactId>
52
+			<scope>test</scope>
53
+			<exclusions>
54
+				<exclusion>
55
+					<groupId>org.junit.vintage</groupId>
56
+					<artifactId>junit-vintage-engine</artifactId>
57
+				</exclusion>
58
+			</exclusions>
59
+		</dependency>
60
+		<!--mysql -->
61
+		<dependency>
62
+			<groupId>mysql</groupId>
63
+			<artifactId>mysql-connector-java</artifactId>
64
+		</dependency>
65
+		<!--代码生成 -->
66
+		<dependency>
67
+			<groupId>com.baomidou</groupId>
68
+			<artifactId>mybatis-plus-generator</artifactId>
69
+			<version>3.2.0</version>
70
+		</dependency>
71
+		<dependency>
72
+			<groupId>org.apache.velocity</groupId>
73
+			<artifactId>velocity-engine-core</artifactId>
74
+			<version>2.1</version>
75
+		</dependency>
76
+		<dependency>
77
+			<groupId>org.freemarker</groupId>
78
+			<artifactId>freemarker</artifactId>
79
+			<version>2.3.29</version>
80
+		</dependency>
81
+		<dependency>
82
+			<groupId>org.projectlombok</groupId>
83
+			<artifactId>lombok</artifactId>
84
+			<optional>true</optional>
85
+		</dependency>
86
+		<dependency>
87
+			<groupId>org.springframework.boot</groupId>
88
+			<artifactId>spring-boot-starter</artifactId>
89
+		</dependency>
90
+		<dependency>
91
+			<groupId>com.baomidou</groupId>
92
+			<artifactId>mybatis-plus-boot-starter</artifactId>
93
+			<version>3.2.0</version>
94
+		</dependency>
95
+		<dependency>
96
+			<groupId>com.ibeetl</groupId>
97
+			<artifactId>beetl</artifactId>
98
+			<version>3.0.13.RELEASE</version>
99
+		</dependency>
96 100
 
97
-        <!-- 日志-->
98
-        <dependency>
99
-            <groupId>ch.qos.logback</groupId>
100
-            <artifactId>logback-classic</artifactId>
101
-        </dependency>
101
+		<!-- 日志 -->
102
+		<dependency>
103
+			<groupId>ch.qos.logback</groupId>
104
+			<artifactId>logback-classic</artifactId>
105
+		</dependency>
102 106
 
103
-        <!-- gbase依赖包 -->
104
-        <dependency>
105
-            <groupId>com.gbase8s</groupId>
106
-            <artifactId>ifxjdbc</artifactId>
107
-            <version>1.0</version>
108
-        </dependency>
109
-        <dependency>
110
-            <groupId>com.gbase</groupId>
111
-            <artifactId>druid</artifactId>
112
-            <version>1.0.28</version>
113
-        </dependency>
114
-    </dependencies>
107
+		<!-- gbase依赖包 -->
108
+		<dependency>
109
+			<groupId>com.gbase8s</groupId>
110
+			<artifactId>ifxjdbc</artifactId>
111
+			<version>1.0</version>
112
+		</dependency>
113
+		<dependency>
114
+			<groupId>com.gbase</groupId>
115
+			<artifactId>druid</artifactId>
116
+			<version>1.0.28</version>
117
+		</dependency>
118
+	</dependencies>
115 119
 
116
-    <!--deploy-->
117
-    <distributionManagement>
118
-        <repository>
119
-            <id>nexus</id>
120
-            <!--名称自己定义-->
121
-            <name>release</name>
122
-            <url>http://10.10.1.25:8760/repository/host_repository/</url>
123
-        </repository>
124
-    </distributionManagement>
125
-    <dependencyManagement>
126
-        <dependencies>
127
-            <dependency>
128
-                <groupId>org.springframework.cloud</groupId>
129
-                <artifactId>spring-cloud-dependencies</artifactId>
130
-                <version>${spring-cloud.version}</version>
131
-                <type>pom</type>
132
-                <scope>import</scope>
133
-            </dependency>
134
-        </dependencies>
135
-    </dependencyManagement>
120
+	<!--deploy -->
121
+	<distributionManagement>
122
+		<repository>
123
+			<id>nexus</id>
124
+			<!--名称自己定义 -->
125
+			<name>release</name>
126
+			<url>http://10.10.1.25:8760/repository/host_repository/</url>
127
+		</repository>
128
+	</distributionManagement>
129
+	<dependencyManagement>
130
+		<dependencies>
131
+			<dependency>
132
+				<groupId>org.springframework.cloud</groupId>
133
+				<artifactId>spring-cloud-dependencies</artifactId>
134
+				<version>${spring-cloud.version}</version>
135
+				<type>pom</type>
136
+				<scope>import</scope>
137
+			</dependency>
138
+		</dependencies>
139
+	</dependencyManagement>
136 140
 
137
-    <build>
138
-        <!--定义编译,打包,部署的项目名称-->
139
-        <finalName>${project.artifactId}</finalName>
140
-        <plugins>
141
-            <plugin>
142
-                <groupId>org.springframework.boot</groupId>
143
-                <artifactId>spring-boot-maven-plugin</artifactId>
144
-            </plugin>
145
-            <!--跳过测试代码的编译-->
146
-            <plugin>
147
-                <groupId>org.apache.maven.plugins</groupId>
148
-                <artifactId>maven-surefire-plugin</artifactId>
149
-                <configuration>
150
-                    <skip>true</skip>
151
-                </configuration>
152
-            </plugin>
153
-        </plugins>
154
-    </build>
155
-    <!--使用Spring稳定版本-->
156
-    <repositories>
157
-        <repository>
158
-            <id>spring-milestones</id>
159
-            <name>Spring Milestones</name>
160
-            <url>https://repo.spring.io/milestone</url>
161
-            <!--不下载snapshots快照版-->
162
-            <snapshots>
163
-                <enabled>false</enabled>
164
-            </snapshots>
165
-        </repository>
166
-    </repositories>
141
+	<build>
142
+		<!--定义编译,打包,部署的项目名称 -->
143
+		<finalName>${project.artifactId}</finalName>
144
+		<plugins>
145
+			<plugin>
146
+				<groupId>org.springframework.boot</groupId>
147
+				<artifactId>spring-boot-maven-plugin</artifactId>
148
+			</plugin>
149
+			<!--跳过测试代码的编译 -->
150
+			<plugin>
151
+				<groupId>org.apache.maven.plugins</groupId>
152
+				<artifactId>maven-surefire-plugin</artifactId>
153
+				<configuration>
154
+					<skip>true</skip>
155
+				</configuration>
156
+			</plugin>
157
+		</plugins>
158
+	</build>
159
+	<!--使用Spring稳定版本 -->
160
+	<repositories>
161
+		<repository>
162
+			<id>spring-milestones</id>
163
+			<name>Spring Milestones</name>
164
+			<url>https://repo.spring.io/milestone</url>
165
+			<!--不下载snapshots快照版 -->
166
+			<snapshots>
167
+				<enabled>false</enabled>
168
+			</snapshots>
169
+		</repository>
170
+	</repositories>
167 171
 
168 172
 </project>

+ 24 - 0
src/main/java/com/chinaitop/WebSecurityConfig.java

@@ -0,0 +1,24 @@
1
+package com.chinaitop;
2
+
3
+import org.springframework.context.annotation.Configuration;
4
+import org.springframework.security.config.annotation.web.builders.HttpSecurity;
5
+import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
6
+import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
7
+
8
+@Configuration
9
+@EnableWebSecurity
10
+public class WebSecurityConfig 
11
+extends WebSecurityConfigurerAdapter 
12
+{
13
+
14
+	@Override
15
+    protected void configure(HttpSecurity http) throws Exception {
16
+		http.authorizeRequests()
17
+		.antMatchers("/**")
18
+		.permitAll() //允许所有用户访问所有资源
19
+        .and()
20
+        .csrf().disable(); // 禁用CSRF(防止伪造的跨域攻击)
21
+
22
+        super.configure(http);
23
+    }
24
+}

+ 14 - 2
src/main/resources/application.yml

@@ -20,14 +20,20 @@ spring:
20 20
     username: gbasedbt
21 21
     password: cDbK2S0go8
22 22
     driver-class-name: com.gbasedbt.jdbc.IfxDriver
23
+
24
+management:
25
+  server:
26
+    port: -1
27
+
23 28
 # 注册中心配置
24 29
 eureka:
25 30
   client:
26 31
     service-url:
27
-      defaultZone: http://${spring.cloud.client.ip-address}:9001/eureka/
32
+      defaultZone: http://tj_admin:Admin_1234@${eureka.instance.hostname}:9001/eureka/
28 33
     register-with-eureka: false
29 34
     fetch-registry: false
30 35
   instance:
36
+    hostname: localhost
31 37
     prefer-ip-address: true
32 38
     # 每隔10s发送一次心跳(默认30s)
33 39
     lease-renewal-interval-in-seconds: 10
@@ -46,12 +52,18 @@ spring:
46 52
     username: gbasedbt
47 53
     password: cDbK2S0go8
48 54
     driver-class-name: com.gbasedbt.jdbc.IfxDriver
55
+
56
+management:
57
+  server:
58
+    port: -1
59
+
49 60
 # 注册中心配置
50 61
 eureka:
51 62
   client:
52 63
     service-url:
53
-      defaultZone: http://172.16.0.4:9811/eureka/
64
+      defaultZone: http://tj_admin:Admin_1234@${eureka.instance.hostname}:9001/eureka/
54 65
   instance:
66
+    hostname: 172.16.0.16
55 67
     prefer-ip-address: true
56 68
     # 每隔10s发送一次心跳(默认30s)
57 69
     lease-renewal-interval-in-seconds: 10