- 1、 修改java版本
<properties><java.version>1.8</java.version></properties>
- 2、 maven plugin to build a exec jar
<build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> </plugins> </build>
- 3、 自动配置/扫描的注解
@SpringBootApplication || @EnableAutoConfiguration
- 4、替换默认的配置
@EnableAutoConfiguration(exclude={DataSourceAutoConfiguration.class})
- 5、devtools
<dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-devtools</artifactId> <optional>true</optional> </dependency> </dependencies>
- 排除重启监听的目录或者文件:spring.devtools.restart.exclude=static/,public/
- 保持默认并添加额外的排除:spring.devtools.restart.additional-exclude
- 监听classpath外的文件:spring.devtools.restart.additional-paths
- 完全的关闭重启服务:在main函数中,
System.setProperty("spring.devtools.restart.enabled", "false"); SpringApplication.run(MyApp.class, args);
- 触发文件:spring.devtools.restart.trigger-file
6、自定义restart classloader
新建文件:META-INF/spring-devtools.properties
文件包含:restart.exclude. and restart.include. prefixed properties,具体属性内容为正则表达式
restart.exclude.companycommonlibs=/mycorp-common-[\\w-]+\.jar restart.include.projectcommon=/mycorp-myproj-[\\w-]+\.jar
7、remote application
<build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <configuration> <excludeDevtools>false</excludeDevtools> </configuration> </plugin> </plugins> </build>
在porperties配置文件中添加:spring.devtools.remote.secret=mysecret
- 8、 代理访问设置
spring.devtools.remote.proxy.host
spring.devtools.remote.proxy.port