springboot基礎初識
pom.xml中新增的依賴
<parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.0.0.RELEASE</version> </parent>
<dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency>
</dependencies>
springboot基礎註解
[email protected] 自動配置spring的bean,要通過SpringApplication.run啟動的話該類上必須有這個註解,或者該類上的註解包含這個註解,不然spring啟動不了,因為不是spring裡面的容器類
[email protected] 預設掃了同級的包下的範圍,同時也包含@EnableAutoConfiguration這個註解
[email protected] 配置掃包範圍
3.1.value屬性可以配置多個掃包配置例如:@ComponentScan(value={"com.yirenjie.base.controller","com.yirenjie.order.controller"})
[email protected] 非同步主鍵 使方法執行的時候非同步執行,注意執行的條件要在啟動類加上@EnableAsync表示允許使用非同步註解,
而且該註解預設的掃包範圍是同級包
springboot靜態資源
1.靜態資源的訪問目錄在maven工程下預設是resources目錄下,靜態資源如js,css,jpg可以預設放在其目錄下的static,public等springboot預設的靜態資源目錄,訪問的時候不需要加static、public這個url字首