【springboot】IDEA手动创建SpringBoot简单工程(无插件)

大致步骤

创建Maven工程

引入依赖

提供启动类

详细教程

创建Maven工程

修改pom.xml文件

添加父节点

XML 复制代码
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>3.5.3</version>
    </parent>

添加springboot依赖

XML 复制代码
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
    </dependencies>

添加镜像

XML 复制代码
    <!-- 配置阿里云仓库 -->
    <repositories>
        <repository>
            <id>aliyun-repos</id>
            <url>https://maven.aliyun.com/repository/public</url>
            <releases>
                <enabled>true</enabled>
            </releases>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </repository>
    </repositories>
    <pluginRepositories>
        <pluginRepository>
            <id>aliyun-repos</id>
            <url>https://maven.aliyun.com/repository/public</url>
            <releases>
                <enabled>true</enabled>
            </releases>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </pluginRepository>
    </pluginRepositories>

刷新

修改启动类

java 复制代码
@SpringBootApplication
public class SpringBootCreateManualApplication
{
    public static void main( String[] args )
    {
        SpringApplication.run(SpringBootCreateManualApplication.class,args);
    }
}

添加资源文件

添加配置文件

application.properties

添加简单示例

java 复制代码
package com.zwh.Controller;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class HelloController {
    @RequestMapping("/hello")
    public String Hello(){
        return "Hello World~~~~~~~";
    }
}

使用的java24需要消除警告

java 复制代码
--enable-native-access=ALL-UNNAMED
 
--add-opens java.base/java.lang=ALL-UNNAMED

运行

查看端口

查看结果

http://127.0.0.1:8080/hello

相关推荐
wuminyu19 小时前
Java锁机制之park与futex系统级协同机制解析
java·linux·c语言·jvm·c++
疯狂打码的少年19 小时前
编译程序与解释程序的区别
java·开发语言·笔记
xieliyu.1 天前
Java算法精讲:双指针(三)
java·开发语言·算法
星辰徐哥1 天前
Spring Boot 微服务架构设计与实现
spring boot·后端·微服务
星辰徐哥1 天前
Spring Boot 数据导入导出与报表生成
spring boot·后端·ui
明夜之约1 天前
Spring Boot 自动装配源码
java·spring boot·后端
Leaton Lee1 天前
Spring Boot分层架构详解:从Controller到Service再到Mapper的完整流程
java·spring boot·后端·架构
Micro麦可乐1 天前
Spring Boot 实战:从零设计一个短链系统(含完整代码与数据库设计)
数据库·spring boot·后端·哈希算法·雪花算法·短链系统
Jinkxs1 天前
Resilience4j- 与 Spring Boot 快速集成:自动配置与基础注解使用
java·spring boot·后端
毕设源码_郑学姐1 天前
计算机毕业设计springboot网络相册设计与实现 基于Spring Boot框架的在线相册管理系统开发与应用 Spring Boot驱动的网络影集设计与实践
spring boot·后端·课程设计