SpringBoot的创建方式

SpringBoot创建的五种方式

1.通过Springboot官网链接下载

注意SpringBoot项目的封装方式默认为Jar

需要查看一下,自己的Maven版本是否正确

创建成功

2.通过 aliyun官网链接下载

修改服务路径为阿里云链接

创建成功

3.通过Springboot官网下载

点击,拉到最下方

基础配置,如果想要添加依赖

最后,点击GENERATE生成项目包

import 对应的pom.xml

一直点击next,直到finish打开文件

更改配置信息,完成SpringBoot项目创建

4.通过aliyun官网下载

访问官网

注意必须为单模块

5.将mavenJava改成springboot

<?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>
    <!--添加父工程目录 为了更好的将子目录交给SpringBoot管理-->
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.5.6</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>

    <groupId>com.qcby</groupId>
    <artifactId>springboot122105</artifactId>
    <version>1.0-SNAPSHOT</version>

    <!--添加内容-->
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <!--加载web-->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
    </dependencies>
</project>

加入启动类

package com.qcby.springboot;

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

//扫描所有dao接口
//@MapperScan("com.qcby.springBootDemo1031.dao")
@SpringBootApplication
public class SpringBootDemoApplication {
    public static void main(String[] args) {
        SpringApplication.run(SpringBootApplication.class, args);
    }
}

我们可以使用自己搭建的SpringBoot进行简单的页面输出

在springboot下面创建controller包,并创建一个表现层的方法

package com.qcby.springboot.controller;

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

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@Controller
@RequestMapping("/index")
public class IndexController {
    @RequestMapping("/run")
    public void run(HttpServletResponse response) throws IOException {
        System.out.println("121212");
        response.getWriter().write("hello");
    }
}

直接运行启动类的内容

使用嵌入式的 Servlet 容器 Tomcat,应用无需打成 war 包,内嵌Tomcat

前端页面的显示结果

相关推荐
菜鸟蹦迪1 分钟前
八股文实战之JUC:ArrayList不安全性
java
2501_903238651 分钟前
Spring MVC配置与自定义的深度解析
java·spring·mvc·个人开发
逻各斯12 分钟前
redis中的Lua脚本,redis的事务机制
java·redis·lua
计算机毕设指导614 分钟前
基于Springboot学生宿舍水电信息管理系统【附源码】
java·spring boot·后端·mysql·spring·tomcat·maven
计算机-秋大田21 分钟前
基于Spring Boot的兴顺物流管理系统设计与实现(LW+源码+讲解)
java·vue.js·spring boot·后端·spring·课程设计
计算机小白一个33 分钟前
蓝桥杯 Java B 组之背包问题、最长递增子序列(LIS)
java·数据结构·蓝桥杯
二十雨辰1 小时前
[Java基础]网络编程
java·开发语言
ACGkaka_1 小时前
抓包工具(三)Wireshark代理抓包Java程序的HTTPS请求
java·https·wireshark
Struggle Sheep1 小时前
容器化部署tomcat
java·tomcat
M1A11 小时前
Python语言发展史:从创立到成为全球热门
java