SpringBoot learning (a) - to build a frame

Brief introduction

advantage
  • Spring Boot can operate independently as a jar package, run a Spring Boot project only needs to be run by java -jar xx.jar.
  • Spring Boot can select the embedded Tomcat, Jetty or Undertow, so we do not need to deploy the project package in the form of war.
  • Spring offers a range of starter pom to simplify Maven's load dependent.
  • Spring Boot based on the classpath jar package, class, automatically configured to jar Bean bag type, which will greatly reduce the configuration we want to use. Spring Boot only consider most of the scenes, not all scenarios.
  • Spring Boot-based http, ssh, telnet project run-time monitoring.
  • Spring Boot than by code generation to achieve, but achieved through conditions annotation, which is a new feature of spring 4.x. Spring 4.x configurations and promote the use of Java annotations configuration combinations, and Spring Boot does not require any configuration to achieve all xml configuration of Spring.
note
  • SpringBoot dependent JDK version 1.8 and above.

Engineering structures

Created by Spring Initializr

Project structure

pom.xml

<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.1.9.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.example</groupId>
    <artifactId>demo</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>demo</name>
    <description>Demo project for Spring Boot</description>

    <properties>
        <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>
start up

Enter the browser HTTP: // localhost: 8080 , you can enter the default page

Guess you like

Origin www.cnblogs.com/lgx211/p/11847876.html