开始这个沙雕的旅程:

1、创建maven project项目

group id :cn.yourgroup

artifact id :spring-boot-helloworld

2、在pom.xml中配置springboot包

(1)spring boot 父节点依赖,引入这个之后相关的引入就不需要添加version配置,spring boot会自动选择最合适的版本进行添加。 

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.4.1.RELEASE</version>
    </parent>

(2)指定jdk版本

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <!-- 指定一下jdk的版本 ,这里我们使用jdk 1.8 ,默认是1.6 -->
    <java.version>1.8</java.version>
  </properties>

(3)添加一些依赖包

<dependencies>
    <!-- spring-boot-starter-web: MVC,AOP的依赖包.... -->
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    <!-- <version></version> 由于我们在上面指定了 parent(spring boot) -->
    </dependency>
    <!-- 添加fastjson 依赖包. -->
    <dependency>
        <groupId>com.alibaba</groupId>
        <artifactId>fastjson</artifactId>
        <version>1.2.15</version>
    </dependency>
    <!-- spring boot devtools 依赖包. -->
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-devtools</artifactId>
        <optional>true</optional>
        <scope>true</scope>
    </dependency>
  </dependencies>

3、创建controller类和启动类

(1)Controller类

springboot 菜鸟入门 -- 简单创建hello world

(2)启动类

springboot 菜鸟入门 -- 简单创建hello world

最后启动main方法即可

好了,可以开始你们的表演了。

 

相关文章:

猜你喜欢
相关资源
相似解决方案