SpringBoot的搭建

一:搭建

1.环境要求

  Java7及以上

  Spring Framework4.1.5及以上

2.新建一个maven工程

  SpringBoot的搭建

  SpringBoot的搭建

  SpringBoot的搭建

  SpringBoot的搭建

  

3.pom.xml(生成)

<!-- 必须引入spring-parent,因为里面实现了很多jar的依赖管理,不需要写jar版本 -->
 <!-- spring mvc(这个在springBoot中已经默认集成,只需要添加springboot-web的依赖就行) -->
 <?xml version="1.0" encoding="UTF-8"?>
 <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.caojun</groupId>
     <artifactId>springboot</artifactId>
     <version>0.0.1-SNAPSHOT</version>
     <packaging>jar</packaging>

     <name>springboot</name>
     <description>Demo project for Spring Boot</description>

     <parent>
         <groupId>org.springframework.boot</groupId>
         <artifactId>spring-boot-starter-parent</artifactId>
         <version>1.5.8.RELEASE</version>
         <relativePath/> <!-- lookup parent from repository -->
     </parent>

     <properties>
         <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
         <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
         <java.version>1.8</java.version>
     </properties>

     <dependencies>
         <dependency>
             <groupId>org.springframework.boot</groupId>
             <artifactId>spring-boot-starter-web</artifactId>
         </dependency>

         <dependency>
             <groupId>org.springframework.boot</groupId>
             <artifactId>spring-boot-starter-test</artifactId>
             <scope>test</scope>
         </dependency>
     </dependencies>

     <build>
         <plugins>
             <plugin>
                 <groupId>org.springframework.boot</groupId>
                 <artifactId>spring-boot-maven-plugin</artifactId>
             </plugin>
         </plugins>
     </build>

 </project>

4.这个时候会出现一个Maven Dependencies

  先maven update一下

  

二:测试

1.对自带的程序进行启动

  SpringBoot的搭建

  SpringBoot的搭建

2.新建java程序

  SpringBoot的搭建

 package com.caojun.springboot;

 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestMethod;
 import org.springframework.web.bind.annotation.RestController;

 @RestController
 public class HelloSpringBoot {

     @RequestMapping(value="/hello",method = RequestMethod.GET)
     public String say(){
         return "Hello Spring Boot";
     }
 }

3.重新启动

  去页面上观察效果

  SpringBoot的搭建

三:maven库

  SpringBoot的搭建

  SpringBoot的搭建

上一篇:Tomcat改端口号;修改访问路径,以及配置Context 标签以后Tomcat启动不了


下一篇:JS判断上传图片格式是否正确