spring boot web简易项目(一)

WebDemo

参考地址

官网初始化地址

pom文件引入


<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.0modelVersion>

    <parent>
        <groupId>org.springframework.bootgroupId>
        <artifactId>spring-boot-starter-parentartifactId>
        <version>2.2.7.RELEASEversion>
        <relativePath/>
    parent>

    <groupId>com.footprintgroupId>
    <artifactId>webdemoartifactId>
    <version>1.0-SNAPSHOTversion>
    <name>webDemoname>
    <description>A simple webdescription>

    <properties>
        <project.reporting.outputEncoding>UTF-8project.reporting.outputEncoding>
        <project.build.sourceEncoding>UTF-8project.build.sourceEncoding>
        <java.version>1.8java.version>
        <jquery.version>3.3.1jquery.version>
        <bootstrap.version>4.0.0bootstrap.version>
    properties>

    <dependencies>

        <dependency>
            <groupId>org.springframework.bootgroupId>
            <artifactId>spring-boot-starterartifactId>
        dependency>

        <dependency>
            <groupId>org.springframework.bootgroupId>
            <artifactId>spring-boot-starter-testartifactId>
            <exclusions>
                <exclusion>
                    <groupId>org.junit.vintagegroupId>
                    <artifactId>junit-vintage-engineartifactId>
                exclusion>
            exclusions>
        dependency>

        <dependency>
            <groupId>org.springframework.bootgroupId>
            <artifactId>spring-boot-starter-webartifactId>
        dependency>

        
        <dependency>
            <groupId>org.springframework.bootgroupId>
            <artifactId>spring-boot-starter-thymeleafartifactId>
        dependency>

        
        <dependency>
            <groupId>org.webjarsgroupId>
            <artifactId>bootstrapartifactId>
            <version>${bootstrap.version}version>
        dependency>
        
            
            
            
        

    dependencies>

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

project>

项目目录

spring boot web简易项目(一)_第1张图片

启动类

package com.footprint;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

/**
 * 启动类
 *
 * @author footprint
 * @since 2020-06-10
 * @version 1.0.0
 */
@SpringBootApplication
public class WebDemoApplication {

    /**
     * start
     *
     * @param args args
     */
    public static void main(String[] args) {
        SpringApplication.run(WebDemoApplication.class, args);
    }

}

首页


<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>GTMToolstitle>

    <link rel="stylesheet" th:href="@{/webjars/bootstrap/4.0.0/css/bootstrap.min.css}">
    <script th:src="@{/webjars/jquery/3.0.0/jquery.min.js}">script>
    <script th:src="@{/webjars/bootstrap/4.0.0/js/bootstrap.min.js}">script>

head>
<body>
    工具
body>
html>

Controller

package com.footprint.contorller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * 首页的实现
 */
@Controller
public class IndexController {

    /**
     * 简单首页实现
     *
     * @return nane
     */
    @RequestMapping(value = "/index")
    public String index() {
        return "index";
    }

}

简易的工程搭建完成

你可能感兴趣的:(spring-boot)