当前位置: 首页 > news >正文

创建SprngBoot项目的四种方式

项目环境:

                JDK:1.8+

                maven:3.9.6

第一种:使用IDEA+官网

 

 然后选择自己需要的依赖然后NEXT(选择WEB

在POM.xml文件中直接将版本17的java删除掉即可

<?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.7.18</version><relativePath/> <!-- lookup parent from repository --></parent><groupId>com.qcby</groupId><artifactId>springboot0712</artifactId><version>0.0.1-SNAPSHOT</version><name>springboot0712</name><description>Demo project for Spring Boot</description><url/><dependencies><!-- MySQL 驱动 --><dependency><groupId>mysql</groupId><artifactId>mysql-connector-java</artifactId><version>8.0.33</version></dependency><!-- Thymeleaf 模板引擎 --><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-thymeleaf</artifactId></dependency><!-- Spring Boot Web 支持 --><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId></dependency><!-- 关键修复:MyBatis 官方启动器 --><dependency><groupId>org.mybatis.spring.boot</groupId><artifactId>mybatis-spring-boot-starter</artifactId><version>2.3.1</version> <!-- 专为 Spring Boot 2.7.x 设计 --></dependency><!-- Spring Boot 测试 --><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-test</artifactId><scope>test</scope></dependency><!-- NekoHTML (用于 Thymeleaf 宽松解析) --><dependency><groupId>net.sourceforge.nekohtml</groupId><artifactId>nekohtml</artifactId><version>1.9.22</version></dependency><!--  图像化依赖 --><dependency><groupId>io.springfox</groupId><artifactId>springfox-swagger-ui</artifactId><version>2.9.2</version></dependency><!--引入swagger2依赖 --><dependency><groupId>io.springfox</groupId><artifactId>springfox-swagger2</artifactId><version>2.9.2</version></dependency></dependencies>
</project>

第二种方式 直接从spring 官网下载

网址:https://start.spring.io/

然后在解压    使用IDEA  import进入就可以了

第三种方式:在阿里云官网上下载

网址:https://start.aliyun.com/

 重复上述操作

第四种使用maven java 项目自打造一个spring-boot项目

选择适合自己的公司域名或者随便写都行 

 

接下来开始创建了非常的简单

目录结构如下图

直接上代码

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 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.7.6</version></parent><groupId>com.qcby</groupId><artifactId>maven-java-to-springboot</artifactId><version>1.0-SNAPSHOT</version><!--所需依赖--><dependencies><!--web--><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId></dependency></dependencies></project>
mavenjavatospringboot
package com.qcby.mavenjavatospringboot;import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;@SpringBootApplication//声明该类为springboot 的启动类
public class mavenjavatospringboot {public static void main(String[] args) {SpringApplication.run(mavenjavatospringboot.class,args);}
}
HelloController
package com.qcby.mavenjavatospringboot.controller;import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;@RestController
@RequestMapping("/say")
public class HelloController {@RequestMapping("hello")public String hello(){return "自己创建的spring boot项目成功了";}
}
application.yml
server:port: 8088

 

http://www.lryc.cn/news/590423.html

相关文章:

  • 降本增效利器:汽车制造中EtherCAT转PROFIBUS DP网关应用探析
  • 快速开发汽车充电桩的屏幕驱动与语音提示方案
  • 使用 SeaTunnel 建立从 MySQL 到 Databend 的数据同步管道
  • Mysql系列--1、库的相关操作
  • 在 IntelliJ IDEA 中添加框架支持的解决方案(没有出现Add Framework Support)
  • AI学习笔记三十一:YOLOv8 C++编译测试(OpenVINO)
  • 使用Telegraf从工业物联网设备收集数据的完整指南
  • Beautiful Soup(BS4)
  • ABP VNext + EF Core 二级缓存:提升查询性能
  • AI炒作,AGI或在2080年之前也无法实现,通用人工智能AGI面临幻灭
  • 【RTSP从零实践】13、TCP传输AAC格式RTP包(RTP_over_TCP)的RTSP服务器(附带源码)
  • 50天50个小项目 (Vue3 + Tailwindcss V4) ✨ | AutoTextEffect(自动打字机)
  • 使用Whistle自定义接口返回内容:Mock流式JSON数据全解析
  • SQL性能分析
  • C# --- 单例类错误初始化 + 没有释放资源导致线程泄漏
  • 【Linux】如何使用nano创建并编辑一个文件
  • 动态规划题解_打家劫舍【LeetCode】
  • 编译原理第四到五章(知识点学习/期末复习/笔试/面试)
  • 部分排序算法的Java模拟实现(复习向,非0基础)
  • AWS ML Specialist 考试备考指南
  • 【Qt】麒麟系统安装套件
  • uniapp写好的弹窗组件
  • OWASP Top 10 攻击场景实战
  • 在 CentOS 8 上彻底卸载 Kubernetes(k8s)
  • 01 启动流程实例
  • ICMR-2025 | 杭电多智能体协作具身导航框架!MMCNav:基于MLLM的多智能体协作户外视觉语言导航
  • 钱包核心标准 BIP32、BIP39、BIP44:从助记词到多链钱包的底层逻辑
  • STM32F4踩坑小记——使用HAL库函数进入HardFault
  • 蓝光三维扫描技术:手机闪光灯模块全尺寸3D检测的高效解决方案
  • HTML基础知识 二(创建容器和表格)