src/main/java:存放代码
src/main/resources
static: 存放静态⽂件,⽐如 css、js、image,
templates:存放静态⻚⾯jsp,html,tpl
confifig:存放配置⽂件,application.properties
resources:
META/resources > resources > static > public
默认配置
spring.resources.static-locations = classpath:/METAINF/resources/,classpath:/resources/,classpath:/static/,classpath:/public/
可修改扩展寻找路径
一般在根目录
推荐第⼆种⽅式,不然漏配置扫描包,项⽬庞⼤,出现问题则难排查
pom文件新增maven插件
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
如果没有加,则执⾏jar包 ,报错如下
java -jar spring-boot-demo-0.0.1-SNAPSHOT.jar
no main manifest attribute, in spring-boot-demo-0.0.1-SNAPSHOT.jar
构建:mvn install
构建跳过测试类 mvn install -Dmaven.test.skip=true
target⽬录下有对应的jar包就是打包后项⽬
进到对应的target⽬录启动 java -jar xxxxx.jar 即可
想后台运⾏,就⽤守护进程 nohup java -jar xxx.jar &
打包后的压缩包结构
example.jar
|
+-META-INF
| +-MANIFEST.MF
+-org
| +-springframework
| +-boot
| +-loader
| +-<spring boot loader classes>
+-BOOT-INF
+-classes
| +-mycompany
| +-project
| +-YourClasses.class
+-lib
+-dependency1.jar
+-dependency2.jar