- 下载并安装jdk:
jdk官网下载地址(jdk x64):点击打开链接
下载后的文件:jdk-8u171-windows-x64.exe
自定义安装jdk和jre(可选)。我都安装了。
path环境变量:
配置环境变量(program_path应用程序的访问路径):
测试jdk环境变量是否配置成功:
- 下载并使用eclipse:
eclipse x64官网下载地址(压缩包版本):点击下载
下载后的文件:eclipse-jee-oxygen-3a-win32-x86_64.zip
解压后即可使用,我习惯上配置环境变量(几乎我每一个程序都会配置)、
这样就可以使用运行(Win + R)输入"eclipse"快速打开eclipse
eclipse OXYGEN如下:(很漂亮吧^_^)
- 下载Maven,并在将Maven整合在eclipse上
Maven的官网下载地址(压缩包版本):点我下载
下载后的文件:apache-maven-3.5.3-bin.zip
解压倒任意目录,习惯上把他和eclipse文件目录并列(我的习惯)
配置环境变量:
测试maven环境变量是否配置成功:
eclipse整合maven:
修改maven下的conf\settings.xml设置文件:
添加本地仓库D:\Maven-Repository,其他可以默认。
<!-- localRepository
| The path to the local repository maven will use to store artifacts.
|
| Default: ${user.home}/.m2/repository
<localRepository>/path/to/local/repo</localRepository>
-->
<localRepository>D:\Maven-Repository</localRepository>
打开eclipse,Window--->Preferences--->Maven
选择installations--->Add--->Directory
刚才添加的打上✔对号,点击apply,然后点击Apply and Close即可
选择maven的配置文件
- 创建springboot项目
应用eclipse新建一个maven项目:
打开pom.xml
访问springboot官网:点击我
我们根据官网上的示例,写一个springboot的小程序
引入springboot 2.0.2的maven依赖。
复制依赖:
pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.mfc</groupId>
<artifactId>springboot</artifactId>
<version>0.0.1-SNAPSHOT</version>
<!-- 引入springboot父类包 -->
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.2.RELEASE</version>
</parent>
<dependencies>
<!-- 引入spring-boot包 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
</project>
仿照springboot官网示例,
编写SpringBoot的Java文件,在页面访问 Hello World!
package hello;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
@Controller
@EnableAutoConfiguration
public class SampleController {
@RequestMapping("/")
@ResponseBody
String home() {
return "Hello World!";
}
public static void main(String[] args) throws Exception {
SpringApplication.run(SampleController.class, args);
}
}
运行程序,Hello World!
- 文章总结:
1.下载安装jdk,配置环境变量
2.下载安装eclipse,配置环境变量
3.下载安装maven,配置环境变量,配置maven本地仓库,并将maven整合倒eclipse上
4.用eclipse新建一个maven项目,并引用springboot的jar包依赖,编写代码。运行并访问Hello World!