一、开发时,配置服务的配置使用本地路径,不使用svn和git,因为后者每个开发人员都会修改配置,导致别人也拿到其他人修改的配置,本地配置示例如下:
spring:
application:
name: simple-config-server
cloud:
config:
server:
default-label: trunk
native:
searchLocations: file:///D:\works\smart\simple-config-repo
profiles:
active: native
二、对于生产环境部署到阿里云的,使用不了docker,因为docker文件通常有几百兆,部署时上传很慢。不但不能使用docker,打包时也没有必要包含所有的包,如果去掉依赖包,编译完后每个jar只有几百k,这样部署起来就方便多了。可以如下设置pom编译选项:
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>ebtins.smart.proxy.SmartProxyApplication</mainClass>
<classpathPrefix>lib/</classpathPrefix>
</manifest>
</archive>
</configuration>
</plugin>
</plugins>
<defaultGoal>compile</defaultGoal>
</build>
这样你生产环境的服务目录将如下,simple-service.jar只有几百K。
simple-service.jar simple-service.sh lib logs
三、使用脚本启动和关闭服务,centos下的脚本启动和关闭可以如下: