终于是考完期末,感觉有一门数学很危险挺容易挂的,现在也只能听天由命了。然后摆了几天,看了点动画,看了两本推理小说,生了场大病。
maven一般从远程仓库拉取依赖(jar包)到本地仓库,可以在maven目录下的conf/settings.xml配置本地仓库地址,否则默认拉取到c盘。相应的也可以设置mirror镜像,下载依赖更快~经典阿里云
然后idea-file-settings-build tools-maven配置自己安装的maven(不要用idea内置maven),用户设置还有本地仓库。
idea右侧的maven选项卡会有很多maven插件,maven出现问题也可以随时更新。
war包是在tomcat(web服务器)上运行的专用格式,程序最终要打包成war包,但是springboot内置了tomcat,因此只需要打包成jar包就行了。
<parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.0.1.RELEASE</version> <relativePath/> <!-- lookup parent from repository --> </parent>
这段为本项目依赖于的一个父项目,其中version便是使用的springboot的版本号
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency>
这段是web依赖,提供了springMVC的相关依赖
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency>
这段是测试程序的依赖。
resources目录下static为网站静态资源,如图片,css,js,template目录下为html的一些模板。
但是前后端分离的开发会采用vue等框架,而不会把前端资源放到这两个目录下面。
先研究下Controller的建立,类上方加注解@Controller或者@RestController即认为该类为控制器,然后对应方法加上@GetMapping或者@RequestMapping选择路径
开发环境热部署需要使用到springboot-devtools,无需重启应用即可重新编译。只需要将依赖加入到pom中,然后到application.yml中配置devtools
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-devtools</artifactId> <optional>true</optional> </dependency>
spring.devtools.restart.enabled=true
#热部署生效
spring.devtools.restart.additional-paths=src/main/java
#设置重启目录
打开Settings页面,在左边的菜单栏依次找到
Build,Execution,Deployment-Compile, Build project automatically
按Ctrl+Shift+Alt+/快捷键调出Maintenance页面,单击Registry,勾选
compiler.automake.allow.when.app.runningJttE.21以后版本的idea没有这个选项要去settings里找到 Advansed Settings勾选Allow auto-make那个选项就可以了
做完这些步骤,若在idea中修改代码,则项目自动重启
浙公网安备 33010602011771号