作为分布式项目的底层,会对项目模块进行规划和划分,因此,我需要对项目重构的功能模块进行整理。
在项目1.0版本时,在qa环境中并不能跟踪到服务的异常,经常出现服务不可用时,测试人员以为代码问题就提出bug。但当你去排查时,很难或者无法重现之前“bug”时的现场,因此,要对项目的框架进行一次升级。
因此对项目结构进行如下规范
├─sc2-parent
│ └─sc2-common
├─sc2-web-deploy
│ ├─deploy-api
│ ├─deploy-core
org.springframework.boot
spring-boot-starter-parent
2.2.5.RELEASE
org.springframework.cloud
spring-cloud-dependencies
Hoxton.SR3
pom
import
org.apache.maven.plugins
maven-checkstyle-plugin
3.1.1
config/checkStyle/google_checks.xml
config/checkStyle/suppressions.xml
UTF-8
true
false
true
false
validate
validate
true
true
google_checks.xml 配置检查规则
io.fabric8
docker-maven-plugin
${docker.plugin.version}
${docker.host}
${docker.registry}
${docker.username}
${docker.password}
${docker.registry}/${docker.namespace}/${project.name}:${project.version}
${project.basedir}/Dockerfile
src/main/resources
true
org.hibernate.validator
hibernate-validator
javax.validation
validation-api
org.springframework.boot
spring-boot-starter-actuator
org.springframework.cloud
spring-cloud-starter-hystrix
${spring-cloud-hystrix-version}
org.springframework.cloud
spring-cloud-starter-hystrix-dashboard
${spring-cloud-hystrix-version}
org.springframework.cloud
spring-cloud-starter-turbine
${spring-cloud-hystrix-version}
com.netflix.eureka
eureka-client
org.springframework.boot
spring-boot-starter-actuator
4.0.0
com.bobycloud
sc2-parent
0.0.1-SNAPSHOT
pom
${project.artifactId}
UTF-8
2.1.1
2.2.5.RELEASE
Hoxton.SR3
1.4.7.RELEASE
1.0.2
0.9.0.RELEASE
1.2.67
1.2.14
2.2.3
28.2-jre
1.8
1.8
3.1
2.7.0
1.5.22
1.9.4
1.3.3
1.21
3.0.3
3.7
1.13
9.0.10
172.16.30.184
http://172.16.30.184:2375
library
0.32.0
org.springframework.boot
spring-boot-starter-parent
2.2.5.RELEASE
org.springframework.cloud
spring-cloud-dependencies
Hoxton.SR3
pom
import
com.google.guava
guava
${guava-version}
${project.name}
src/main/resources
true
org.springframework.boot
spring-boot-maven-plugin
${spring-boot-version}
org.apache.maven.plugins
maven-compiler-plugin
${maven-compiler-plugin-version}
${maven.compiler.target}
org.apache.maven.plugins
maven-checkstyle-plugin
3.1.1
config/checkStyle/google_checks.xml
config/checkStyle/suppressions.xml
UTF-8
true
false
true
false
validate
validate
true
true
io.fabric8
docker-maven-plugin
${docker.plugin.version}
${docker.host}
${docker.registry}
${docker.username}
${docker.password}
${docker.registry}/${docker.namespace}/${project.name}:${project.version}
${project.basedir}/Dockerfile
org.apache.maven.plugins
maven-checkstyle-plugin
nexus-releases
Nexus Release Repository
http://10.10.11.95/repository/maven-releases/
nexus-snapshots
Nexus Snapshot Repository
http://10.10.11.95/repository/maven-snapshots/
dev
dev
true
test
test
prod
prod
sc2-common
4.0.0
sc2-common
0.0.1-SNAPSHOT
javax.servlet
javax.servlet-api
com.google.guava
guava
org.hibernate.validator
hibernate-validator
javax.validation
validation-api
org.springframework
spring-context
org.springframework.boot
spring-boot-starter-data-redis
org.springframework.boot
spring-boot-starter-web
org.springframework.boot
spring-boot-devtools
true
org.springframework
spring-web
io.github.openfeign
feign-core
org.springframework
spring-webmvc
org.springframework.boot
spring-boot-starter-actuator
org.springframework.cloud
spring-cloud-starter-hystrix
${spring-cloud-hystrix-version}
org.springframework.cloud
spring-cloud-starter-hystrix-dashboard
${spring-cloud-hystrix-version}
org.springframework.cloud
spring-cloud-starter-turbine
${spring-cloud-hystrix-version}
com.netflix.eureka
eureka-client
org.springframework.cloud
spring-cloud-starter-ribbon
${spring-cloud-hystrix-version}
org.springframework.cloud
spring-cloud-starter-zipkin
org.springframework.cloud
spring-cloud-starter-openfeign
org.springframework.cloud
spring-cloud-context
org.springframework.boot
spring-boot-starter-actuator
com.alibaba.spring
spring-context-support
${spring-context-support-version}
org.springframework.cloud
spring-cloud-starter-alibaba-nacos-discovery
${nacos-version}
org.postgresql
postgresql
org.apache.tomcat
tomcat-jdbc
${tomcat-jdbc-version}
org.mybatis.spring.boot
mybatis-spring-boot-starter
${mybatis-spring-boot-starter-version}
com.fasterxml.jackson.core
jackson-databind
com.alibaba
fastjson
${fastjson-version}
log4j
log4j
${log4j-version}
io.springfox
springfox-swagger-ui
${swagger2.version}
io.springfox
springfox-swagger2
${swagger2.version}
io.swagger
swagger-annotations
${swagger2-annotations.version}
commons-beanutils
commons-beanutils
${commons-beanutils-version}
compile
commons-fileupload
commons-fileupload
${commons-fileupload-version}
org.apache.commons
commons-lang3
${commons-lang3-version}
commons-codec
commons-codec
${commons-codec-version}
org.projectlombok
lombok
org.springframework.boot
spring-boot-starter-test
test
com.bobycloud
sc2-parent
0.0.1-SNAPSHOT
4.0.0
deploy-api
org.apache.maven.plugins
maven-compiler-plugin
com.bobycloud
sc2-common
0.0.1-SNAPSHOT
com.bobycloud.webdeploy
sc2-web-deploy
${revision}
4.0.0
deploy-core
war
deploy
org.apache.maven.plugins
maven-checkstyle-plugin
org.springframework.boot
spring-boot-maven-plugin
org.apache.maven.plugins
maven-compiler-plugin
src/main/resources
true
com.bobycloud.webdeploy
deploy-api
${project.version}
com.bobycloud.webdeploy
sc2-web-deploy
${revision}
/**
* @ClassName: CoreApplication
* @Description: 启动类
* @author 作者
* @date 2019年9月24日 下午5:58:01
*/
@Import({SwaggerConfiguration.class, IDSnowflakeCreate.class, IDRedisCreate.class, ExceptionResolver.class})
@MapperScan(basePackages = "com.bobycloud.deploy.service.dao.*")
@EnableDiscoveryClient
@EnableFeignClients
@EnableTurbine
@EnableHystrixDashboard
@EnableCircuitBreaker
@Configuration
@RefreshScope
@SpringBootApplication
public class CoreApplication {
public static void main(String[] args) {
SpringApplication.run(CoreApplication.class, args);
}
}
server:
port: 9090
servlet:
context-path: /${spring.application.name}
spring:
application:
name: deploy
admin:
enabled: true
profiles:
active: dev
cloud:
nacos:
discovery:
server-addr: ${NACOS-HOST:172.16.30.184}:${NACOS-PORT:8858}
metadata:
management.context-path: /${spring.application.name}/actuator
config:
server-addr: ${spring.cloud.nacos.discovery.server-addr}
file-extension: yml
shared-configs:
- ${spring.application.name}-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
redis:
#内网
host: 172.16.30.184
port: 6379 #可不配,因为底层默认值为6379
datasource:
type: org.apache.tomcat.jdbc.pool.DataSource
driver-class-name: org.postgresql.Driver
url: jdbc:postgresql://172.16.30.184:5432/qa_theach
username: qa_theach
password: 'qa_theach'
tomcat:
testWhileIdle: true
testOnBorrow: true
testOnReturn: false
validationInterval: 30000
timeBetweenEvictionRunsMillis: 30000
maxActive: 100
minIdle: 10
maxWait: 10000
initialSize: 10
removeAbandonedTimeout: 60
removeAbandoned: true
logAbandoned: true
minEvictableIdleTimeMillis: 30000
jmxEnabled: true
boot:
admin:
client:
url: "http://localhost:8080"
mail:
host: smtp.126.com
username:
password:
zipkin:
service:
name: /${spring.application.name}
base-url: http://172.16.30.184:9411
management:
endpoints:
web:
exposure:
include: "*"
endpoint:
health:
show-details: ALWAYS
swagger:
servletPath: /${spring.application.name}
basePackage: 'com.bobycloud.deploy'
title: 'deploy项目API'
desc: '最终解释权归研发部(软件组)所有'
version: '1.0'
serviceTermsUrl: '服务条款对应的网址'
contactName: '研发部-软件组'
contactEmail: '[email protected]'
contactUrl: '作者网址'
license: '许可'
licenseUrl: '许可对应的网址'
#id
ids:
snowflake:
datacenterId: 1
workerId: 1
redis:
step: 3
feign:
hystrix:
enabled: true
#hystrix的超时时间
hystrix:
command:
default:
execution:
timeout:
enabled: true
isolation:
thread:
timeoutInMilliseconds: 9000
#ribbon的超时时间
ribbon:
ReadTimeout: 3000
ConnectTimeout: 3000
turbine:
app-config: ${spring.application.name}
cluster-name-expression: metadata['cluster']
aggregator:
clusterConfig: CLOUD-SIMPLE-SERVICE #turbine监控的服务名称,可以多个