File tree Expand file tree Collapse file tree 8 files changed +100
-13
lines changed
java/com/newtouch/cloud/demo/config
main/java/com/newtouch/cloud/demo/organization/service Expand file tree Collapse file tree 8 files changed +100
-13
lines changed Original file line number Diff line number Diff line change 2
2
3
3
import org .springframework .boot .SpringApplication ;
4
4
import org .springframework .boot .autoconfigure .SpringBootApplication ;
5
+ import org .springframework .cloud .client .discovery .EnableDiscoveryClient ;
6
+ import org .springframework .cloud .config .server .EnableConfigServer ;
5
7
6
8
@ SpringBootApplication
9
+ @ EnableDiscoveryClient
10
+ @ EnableConfigServer
7
11
public class ConfigApplication {
8
12
9
13
public static void main (String [] args ) {
Load Diff This file was deleted.
Original file line number Diff line number Diff line change
1
+ spring :
2
+ application :
3
+ name : config-server
4
+ cloud :
5
+ config :
6
+ server :
7
+ accept-empty : false
8
+ profiles :
9
+ active : native
10
+ eureka :
11
+ instance :
12
+ prefer-ip-address : true
13
+ hostname : ${spring.application.name}
14
+ client :
15
+ serviceUrl :
16
+ defaultZone : http://service-eureka:8090/eureka/
17
+ server :
18
+ port : 8888
19
+
20
+ ---
21
+ spring :
22
+ profiles : git
23
+ cloud :
24
+ config :
25
+ server :
26
+ git :
27
+ uri : https://github.com/LikeSimple/spring-cloud-config
28
+ refresh-rate : 15 # 默认为0,即每次请求都刷新远程信息;否则为指定多久后才刷新
29
+ default-label : master # 指定默认版本,可以是commit id, tag, branch name
30
+ search-paths : repos, {application}/{profile} # 指定搜索子路径以及搜索格式
31
+ timeout : 5
32
+ # force-pull: true
33
+ # deleteUntrackedBranches: true
34
+ # clone-on-start: true
35
+ # 模板形式
36
+ # repos:
37
+ # development:
38
+ # pattern:
39
+ # - '*/development'
40
+ # - '*/staging'
41
+ # cloneOnStart: true
42
+ # uri: https://github.com/development/config-repo
43
+ # username: trolley
44
+ # password: strongpassword
45
+ # 或者也可以使用ssh形式,会使用~/.ssh/下的配置 ,只支持rsa形式,Gti服务器应在known_hosts文件中,HTTPS PROXY则配置在~/.git/config中或者使用启动参数-Dhttps.proxyHost and -Dhttps.proxyPort
46
+ ---
47
+ spring :
48
+ profiles : local
49
+ cloud :
50
+ config :
51
+ server :
52
+ git :
53
+ uri : file://${user.home}/develop/config-repo # 当URI以file开头,则直接读取本地clone目录,主要用于测试,如果在生产环境需要以共享目录形式给所有的配置服务器挂载;该目录为默认搜索
54
+ refresh-rate : 15 # 默认为0,即每次请求都刷新远程信息;否则为指定多久后才刷新
55
+ default-label : master # 指定默认版本,可以是commit id, tag, branch name
56
+ search-paths : repos* # 子目录搜索,支持目录通配符
57
+ timeout : 5
58
+
59
+ ---
60
+ spring :
61
+ profiles : native
62
+ cloud :
63
+ config :
64
+ server :
65
+ native :
66
+ search-locations : classpath:/config, file:./{application}/{profile}/{label}
67
+ ---
68
+ spring :
69
+ profiles : vault
70
+ cloud :
71
+ config :
72
+ server :
73
+ vault :
74
+ host : 127.0.0.1
75
+ port : 8200
76
+ scheme : http
77
+ backend : secret
78
+ default-key : application
79
+ profile-separator : " ,"
80
+ kv-version : 2 # For vault version >= 0.10.0
81
+ skip-ssl-validation : false
82
+ timeout : 5
83
+ namespace : null
Original file line number Diff line number Diff line change @@ -24,11 +24,10 @@ spring:
24
24
baseline-on-migrate : true
25
25
server :
26
26
port : 9999
27
- eureka :
27
+ eureka : # 注册中心
28
28
instance :
29
29
prefer-ip-address : true
30
30
hostname : ${spring.application.name}
31
31
client :
32
32
serviceUrl :
33
- defaultZone : http://service-eureka:8090/eureka/
34
-
33
+ defaultZone : http://service-eureka:8090/eureka/
Original file line number Diff line number Diff line change 1
1
package com .newtouch .cloud .demo .organization .service ;
2
2
3
- import com .newtouch .cloud .demo .organization .controller .vo .UserDetails ;
4
-
5
-
6
3
public interface OrganizationService {
7
4
8
- UserDetails getUserDetails ( String username );
5
+
9
6
10
7
}
Original file line number Diff line number Diff line change 1
1
import com .newtouch .cloud .demo .organization .OrganizationApplication ;
2
2
import com .newtouch .cloud .demo .organization .persistence .mapper .CorporationMapper ;
3
+ import org .jetbrains .annotations .NotNull ;
3
4
import org .junit .ClassRule ;
4
5
import org .junit .Test ;
5
6
import org .junit .runner .RunWith ;
@@ -24,20 +25,23 @@ public class OrganizationApplicationTests {
24
25
private CorporationMapper corporationMapper ;
25
26
26
27
@ ClassRule
27
- public static MySQLContainer db = new MySQLContainer ("mysql:5.7" ).withDatabaseName ("organization" );
28
+ private static MySQLContainer db = new MySQLContainer ("mysql:5.7.22" );
29
+
28
30
29
31
@ ClassRule
30
32
public static GenericContainer redis = new GenericContainer ("redis:4.0.12-alpine" )
31
33
.withExposedPorts (6379 );
32
34
33
35
@ ClassRule
34
36
public static GenericContainer rabbitMq = new GenericContainer ("rabbitmq:3.7.7-management-alpine" )
35
- .withExposedPorts (5672 );
37
+ .withExposedPorts (5672 )
38
+ .withEnv ("RABBITMQ_DEFAULT_USER" ,"rabbit" )
39
+ .withEnv ("RABBITMQ_DEFAULT_PASS" , "123456" );
36
40
37
41
static class Initializer implements ApplicationContextInitializer <ConfigurableApplicationContext > {
38
42
39
43
@ Override
40
- public void initialize (ConfigurableApplicationContext configurableApplicationContext ) {
44
+ public void initialize (@ NotNull ConfigurableApplicationContext configurableApplicationContext ) {
41
45
TestPropertyValues .of (
42
46
"spring.redis.port=" + redis .getFirstMappedPort (),
43
47
"spring.rabbitmq.port=" + rabbitMq .getFirstMappedPort ()
Original file line number Diff line number Diff line change @@ -13,8 +13,9 @@ spring:
13
13
datasource :
14
14
driver-class-name : org.testcontainers.jdbc.ContainerDatabaseDriver
15
15
url : jdbc:tc:mysql://hostname:3306/dbname?TC_INITSCRIPT=init_db.sql
16
- # username: root
17
- # password: 1234
16
+ rabbitmq :
17
+ username : rabbit
18
+ password : 123456
18
19
19
20
eureka :
20
21
client :
You can’t perform that action at this time.
0 commit comments