SpringBoot
SpringBoot:框架集成工具,自带tomcat服务器。特点:版本仲裁,自动装配。
SpringBoot核心配置文件:application和bootstrap,bootstrap会优先于application加载
- bootstrap为系统级配置文件,会优先下载SpringCloud中配置中心的配置
- application 配置文件是应用级别的,当前项目所需的配置
配置文件有两种properties与yml
- properties:为key=value形式
- yml:为key:value形式,":"号后需要一个空格,树状分支,配置结构易懂
SpringBoot核心注解组成:@SpringBootApplication
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Inherited
@SpringBootConfiguration
@EnableAutoConfiguration
@ComponentScan(excludeFilters = { @Filter(type = FilterType.CUSTOM, classes = TypeExcludeFilter.class),
@Filter(type = FilterType.CUSTOM, classes = AutoConfigurationExcludeFilter.class) })
@ConfigurationPropertiesScan
SpringBoot项目启动方式:
- 执行主配置类(@SpringBootApplication)
- 在项目的根目录下打开CMD,执行mvn spring-boot:run
- 通过mvn命令在项目根目录下或者在idea中执行mvn命令,mvn install打包成jar,在target中执行java -jar xxxx.jar包
SpringBoot项目热部署方式:
- 引入spring-boot-devtools热部署的Jar
<dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-devtools</artifactId> <optional>true</optional> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <configuration> <fork>true</fork> </configuration> </plugin> </plugins> </build> 并且在配置文件中开启: debug: true spring: devtools: restart: enabled: true #设置开启热部署 freemarker: cache: false #页面不加载缓存,修改即时生效
- 引入插件JRebel-----收费
浙公网安备 33010602011771号