myeclipse10创建Springboot的小demo之helloworld
1.环境:myeclipse10,maven3.3.9,jdk1.8
2.配置jdk1.8环境变量,maven环境变量
3.创建新的工作空间SpringBoot
4.创建maven项目
5.选择创建简单的项目,这样创建的项目会有完整的目录结构,我试着不选择创建出来的项目出现问题,没有搞清楚怎么回事
所以先选择创建简单项目,点击下一步,填写相关信息
6.填写信息,其中Compiler Level只能选到1.6不知道为什么,但是不影响项目的创建
7.显示目录结构,我重新添加的运行环境1.8,其他也可以,因为后续我要做一个项目用到1.8的环境
8.配置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.study</groupId>
<artifactId>MySpringBoot</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>MySpringBoot</name>
<url>http://maven.apache.org</url>
<!--1.指定版本 -->
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
</properties>
<!--2.父节点依赖,引入后相关配置不用选择版本,spring会自动选择合适添加 -->
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.6.RELEASE</version>
</parent>
<!--3.springboot的web依赖 -->
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
<!--4.插件 -->
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
*** 2,3,4步步很重要,配置完成后,保存,需要稍等一会,会自动加载需要的东西,如果pom,xml报错,需要看看maven的conf目录下的
settings.xml文件
有这么一段配置
<profile>
<id>jdk1.8</id>
<activation>
<activeByDefault>true</activeByDefault>
<jdk>1.8</jdk>
</activation>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion>
</properties>
我选的jdk版本1.8,其他maven插件版本也是1.8的,对应上就行了,然后更新项目
9.写一个启动程序,这个启动程序的包一定是父级包,否则会找不到相应的类而报错
10.启动并访问,直接启动main方法,会出现
11.访问