标签:mic repo vat toc ble sse maven dex new
配置文件,引入基础依赖
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.4.4</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
启动类
@SpringBootApplication
public class MyApplication {
public static void main(String[] args) {
SpringApplication.run(MyApplication.class, args);
}
}
控制层
@RestController
public class testController {
@Autowired
private ObjectMapper objectMapper;
@GetMapping("test")
public Map test(){
Map<Object, Object> map = new HashMap<>();
map.put("msg","hello , boots ! ");
return map;
}
}
注解存在部分一类未导入,enter+alt 按需求导入
测试
注意:启动类与Java文件间应该有文件夹层。首次创建的时候,不存在夹层时有问题。
线上创建
3.1第一种,main方法 -开发时
SpringApplication.run(Springboot01Application.class, args);
3.2第二种,maven插件命令
mvn spring-boot:run
3.3第三种,java jar包方式启动 - 上线时
java -jar springboot_01-0.0.1-SNAPSHOT.jar
所有jar包都可以用这个命令运行
3.4打成war包放在服务器中
重点
@SpringBootConfiguration
@EnableAutoConfiguration
@ComponentScan(
excludeFilters = {@Filter(
type = FilterType.CUSTOM,
classes = {TypeExcludeFilter.class}
), @Filter(
type = FilterType.CUSTOM,
classes = {AutoConfigurationExcludeFilter.class}
)}
)
springboot核心注解
#server.port=8888
server:
port: 8888
#下面就是数组 集合 set...都可以这么写
person: #对象
hobby: #属性
- lanqiu
- zuqiu
- paiqiu
wife:
a,
b,
c
car: [电瓶车,美团自行车]
#map写法
map:
k1: abc
k2: bbc
map2: {k1: v1,k2: v2}
找这个网站:https://www.toyaml.com/index.html
标签:mic repo vat toc ble sse maven dex new
原文地址:https://www.cnblogs.com/lnkD/p/14752751.html