first hello

It is said that spring-boot is a development tool for microservices, try it today. Before trying, take a look at:

 

Spring Boot  is provided by the Pivotal team. It is not a brand-new framework, but integrates existing Spring components, and configures many framework usage methods by default , just like maven integrates all jar packages, so that development Personnel no longer need to define boilerplate configuration, eliminating cumbersome XML configuration and using conventions or annotations instead. So after being familiar with Spring Boot, the development efficiency will be improved by a grade. It is characterized by simplicity, speed and convenience.

 

Sounds good, but does it actually work? Let's see:

 

1. Create a new maven project and edit the pom.xml file as follows:

<?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.example</groupId>  

    <artifactId>spring_boot</artifactId>  

    <version>0.0.1-SNAPSHOT</version>  

  

    <!-- Inherit defaults from Spring Boot -->  

    <parent>  

        <groupId>org.springframework.boot</groupId>  

        <artifactId>spring-boot-starter-parent</artifactId>  

        <version>1.4.0.BUILD-SNAPSHOT</version>  

    </parent>  

  

    <!-- Add typical dependencies for a web application -->  

    <dependencies>  

        <dependency>  

            <groupId>org.springframework.boot</groupId>  

            <artifactId>spring-boot-starter-web</artifactId>  

        </dependency>  

    </dependencies>  

  

    <!-- Package as an executable jar -->  

    <build>  

        <plugins>  

            <plugin>  

                <groupId>org.springframework.boot</groupId>  

                <artifactId>spring-boot-maven-plugin</artifactId>  

            </plugin>  

        </plugins>  

    </build>  

  

    <!-- Add Spring repositories -->  

    <!-- (you don't need this if you are using a .RELEASE version) -->  

    <repositories>  

        <repository>  

            <id>spring-snapshots</id>  

            <url>http://repo.spring.io/snapshot</url>  

            <snapshots><enabled>true</enabled></snapshots>  

        </repository>  

        <repository>  

            <id>spring-milestones</id>  

            <url>http://repo.spring.io/milestone</url>  

        </repository>

    </repositories>  

    <pluginRepositories>  

        <pluginRepository>  

            <id>spring-snapshots</id>  

            <url>http://repo.spring.io/snapshot</url>  

        </pluginRepository>  

        <pluginRepository>  

            <id>spring-milestones</id>  

            <url>http://repo.spring.io/milestone</url>  

        </pluginRepository>  

    </pluginRepositories>  

</project>

 

2.新建如下两个类



 

3.运行Application。运行成功后,后台会有spring boot 的启动信息

 

4.访问http://localhost:8080/hello/SpringBoot,http://localhost:8080/。看到了效果。就这么简单

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326077079&siteId=291194637