多环境配置
在resources目录下,新建不同环境的配置文件
- application-dev.properties
- application-prod.properties
- application-test.properties
在application.properties里面设置当前的配置文件1
spring.profiles.active=dev
Database
MySQL
数据库名称为spring
1 | spring.datasource.url=jdbc:mysql://localhost:3306/spring?useUnicode=true&characterEncoding=utf-8 |
Druid
H2
1 | # H2 |
Servlet
Tomcat
修改服务器端口
1 | server.port=8011 |
Jetty
替换Tomcat
pom.xml1
2
3
4
5
6
7
8
9
10
11
12
13
14<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jetty</artifactId>
</dependency>
Build
War
找到节点1
<packaging>jar</packaging>
- 修改jar为war
- 创建初始化类
1
2
3
4
5class ServletInitializer : SpringBootServletInitializer() {
override fun configure(builder: SpringApplicationBuilder?): SpringApplicationBuilder {
return builder!!.sources(FiatgwApplication::class.java)
}
}
RPC
Thrift
pom.xml
1 | <dependency> |
定义Thrift接口1
2
3
4
5namespace java com.fintend.fiatgw
service FiatGatewaySystemService{
bool exists(1:bool checked)
}
生成Java代码1
thrift --gen java FiatGatewaySystemService.thrift
### gRPC
pom.xml1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-netty</artifactId>
<version>${grpc.version}</version>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-protobuf</artifactId>
<version>${grpc.version}</version>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-stub</artifactId>
<version>${grpc.version}</version>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-testing</artifactId>
<version>${grpc.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.api.grpc</groupId>
<artifactId>proto-google-common-protos</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>com.google.protobuf.nano</groupId>
<artifactId>protobuf-javanano</artifactId>
<version>3.1.0</version>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>protoc-gen-grpc-java</artifactId>
<version>1.9.0</version>
<type>pom</type>
</dependency>