spring boot 是基于spring 开发的脚手架,它可以快速配置spring,简化新Spring应用的初始搭建以及开发过程。该框架使用了特定的方式来进行配置,从而使开发人员不再需要定义样板化的配置。
vscode是微软推出的基于electronic 开发的代码编辑器,可以开发多种语言。
vscode的强大之处在于它的插件机制,通过安装插件,我们可以快速开发相关语言的应用,有了这些插件,vscode的堪比ide.
开发spring boot我们需要安装两个插件包
Language Support for Java(TM) by Red Hat
Java Linting, Intellisense, formatting, refactoring, Maven/Gradle support and more...
Red Hat
Debugger for Java
A lightweight Java debugger for Visual Studio Code
Microsoft
Java Test Runner
Run and debug JUnit or TestNG test cases
Microsoft
Maven for Java
Manage Maven projects, execute goals, generate project from archetype, improve user experience for Java developers.
Microsoft
Java Dependency Viewer
Manage Java Dependencies in VSCode
Microsoft
Visual Studio IntelliCode
AI-assisted development
Microsoft
)
Spring Boot Extension
Extension Pack (5)
Spring Boot Tools
Provides validation and content assist for Spring Boot application.properties
, application.yml
properties files. As well as Boot-specific support for .java
files.
Pivotal
Concourse CI Pipeline Editor
Provides validation and content assist for Concourse CI pipeline and task configuration yml files
Pivotal
Cloudfoundry Manifest YML Support
Adds linting, content assist and hoverinfo's for Cloudfoundry Deployment Manifests (a.k.a. manifest.yml
) files.
Pivotal
Spring Initializr Java Support
A lightweight extension based on Spring Initializr to generate quick start Spring Boot Java projects.
Microsoft
Spring Boot Dashboard
Spring Boot Dashboard for VS Code
Microsoft
也就是通过安装两个扩展包,我们安装了11个扩展。
我们使用maven来构建我们的spring项目,所以我们需要先安装maven.
https://maven.apache.org/
可以在maven官网找到对应操作系统的版本,安装非常简单,需要注意的是添加环境变量。
添加环境变量就是将maven的执行目录放入到系统环境中,这样系统在任何目录下都可以执行maven的命令。
由于国内网络问题,我们需要配置下maven的仓库,在maven的安装目录里面有个conf文件夹,里面有settings.xml,我们修改仓库位置。
<mirrors> <mirror> <id>alimaven</id> <mirrorOf>central</mirrorOf> <name>aliyun maven</name> <url>http://maven.aliyun.com/nexus/content/repositories/central/</url> </mirror> <mirror> <id>nexus-aliyun</id> <mirrorOf>*</mirrorOf> <name>Nexus aliyun</name> <url>http://maven.aliyun.com/nexus/content/groups/public</url> </mirror> <!-- 中央仓库1 --> <mirror> <id>repo1</id> <mirrorOf>central</mirrorOf> <name>Human Readable Name for this Mirror.</name> <url>http://repo1.maven.org/maven2/</url> </mirror> <!-- 中央仓库2 --> <mirror> <id>repo2</id> <mirrorOf>central</mirrorOf> <name>Human Readable Name for this Mirror.</name> <url>http://repo2.maven.org/maven2/</url> </mirror> </mirrors>
找到vscode的个人变量配置文件,添加下面的配置。
"maven.excludedFolders": [ "**/.*", "**/node_modules", "**/target", "**/bin" ], "java.home":"D://Program Files//Java//jdk1.8.0_181",jdk目录 "java.configuration.maven.userSettings": "D://apache-maven-3.6.3//conf//settings.xml",//maven配置文件目录 "maven.executable.path": "D://apache-maven-3.6.3//bin//mvn.cmd",//maven执行命令 "maven.terminal.useJavaHome": true, "maven.terminal.customEnv": [ { "environmentVariable": "JAVA_HOME", "value": "D://Program Files//Java//jdk1.8.0_181"//jdk目录 } ],
输入srping initializr创建spring boot项目
在vscode左侧的文件栏中找到 spring boot dashborad,可以快速启动项目。