zoukankan      html  css  js  c++  java
  • SpringBoot入门:搭建SpringBoot

    springboot的核心原理,自动装配

    一,两种搭建SpringBoot方式

      1.官方:提供了一个快速生成springboot的网站,仅需在官网上配置后下载就可以了,(IDEA集成了这个网站)

    2,直接使用IDEA创建(推荐)

    基本结构

    package com.king.helloworld;
    
    import org.springframework.boot.SpringApplication;
    import org.springframework.boot.autoconfigure.SpringBootApplication;
    
    
    //底层是@Component,所以这个注解本身就是spring的一个组件
    //程序的主入口
    @SpringBootApplication
    public class HelloworldApplication {
    
        public static void main(String[] args) {
            SpringApplication.run(HelloworldApplication.class, args);
        }
    
    }

        

    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>
        <!--有一个父项目,path是空的说明他的父是在线的-->
        <parent>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-parent</artifactId>
            <version>2.4.0</version>
            <relativePath/> <!-- lookup parent from repository -->
        </parent>
        <groupId>com.king</groupId>
        <artifactId>helloworld</artifactId>
        <version>0.0.1-SNAPSHOT</version>
        <name>helloworld</name>
        <description>Demo project for Spring Boot</description>
    
        <properties>
            <java.version>1.8</java.version>
        </properties>
    
        <dependencies>
            <!--web依赖:集成了一个tomcat,配置dispatcherservlet,xml-->
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-web</artifactId>
            </dependency>
    
            <!--spring-boot-starter,springboot所有的依赖都是使用这个开头的-->
    
            <!--单元测试-->
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-test</artifactId>
                <scope>test</scope>
            </dependency>
        </dependencies>
    
        <build>
            <!--打jar包插件-->
            <plugins>
                <plugin>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-maven-plugin</artifactId>
                </plugin>
            </plugins>
        </build>
    
    </project>

    彩蛋

      更换项目端口号

    在application.properties中写入

      自定义编译运行图案(网址:https://www.bootschool.net/ascii-art)

    官方:

    自定义:(通过网站找的模板)

  • 相关阅读:
    C# 多线程传递参数或多个参数
    InnoSetup汉化版打包工具下载-附带脚本模板
    C#使用Protobuf协议-源码分析-附带项目文件
    百度云百度网盘VIP不限速破解版绿色版-实测可用
    (实测可用)GTA5侠盗猎车5中文版破解版迅雷下载地址种子
    串口助手下载-带时间戳的串口助手-极简串口助手-V1.1 自动保存配置参数 能显示收发时间方便调试
    c#tcp多线程服务器实例代码
    C# MVC VS WebAPI
    Android VS IOS
    js玩转数字----取整,四舍五入,数字字符串转换
  • 原文地址:https://www.cnblogs.com/CL-King/p/14031930.html
Copyright © 2011-2022 走看看