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

SpringBoot 01 如何创建 和pom的解析

目录

1  Springboot的创建

步骤

2  项目的书写和运行

 创建service包并在其下写一个service文件

项目的运行 

pom文件的一些配置

parent

web

test

打包

打包过程


1  Springboot的创建

步骤

  • 首先new一个新项目

  • 然后依照如下创建

2  项目的书写和运行

 创建service包并在其下写一个service文件

注意:service一定要放在项目名的包下 这里还有一些注解的解释请仔细观看

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
//返回字符串类型
@RestController
public class HelloController {//接口 http://localhost:8080/hello@RequestMapping("/hello")public String hello(){return "hello world";}
}

项目的运行 

运行项目名包下的Appliaction文件即可

//本身就是spring的一个组件
@SpringBootApplication
public class DemoSpringBootApplication {public static void main(String[] args) {SpringApplication.run(DemoSpringBootApplication.class, args);}}

pom文件的一些配置

parent

<!--有一个父项目-->
<parent><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-parent</artifactId><version>2.7.14</version><relativePath/> <!-- lookup parent from repository -->
</parent>

web
<!--web 依赖 配好了 Tomact servlet .xml-->

<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId>
</dependency>

test

<!--单元测试-->

<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-test</artifactId><scope>test</scope>
</dependency

打包

    <!--打jar包程序--><plugins><plugin><groupId>org.springframework.boot</groupId><artifactId>spring-boot-maven-plugin</artifactId></plugin></plugins>
</build>

打包后会形成一个jar文件,这个jar文件也相当于一个接口。通过在命令窗口执行这个文件也可以达到效果。

打包过程

1

2
3在cmd窗口执行文件

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

相关文章:

  • axios详解
  • Docker分布式仓库
  • SQL注入之万能用户名
  • ubuntu20搭建环境使用的一下指令
  • GAN(生成对抗网络)
  • 实时同步ES技术选型:Mysql+Canal+Adapter+ES+Kibana
  • 禅道后台命令执行漏洞
  • 基于Spark+django的国漫推荐系统--计算机毕业设计项目
  • 向量数据库 Milvus:实现高效向量搜索的技术解析
  • 恒运资本:信创概念再度活跃,华是科技再创新高,南天信息等涨停
  • Synchronized锁升级
  • 记一个宏定义写法
  • 【数据结构】C语言实现栈(详细解读)
  • 3、Spring_容器执行
  • 五、pikachu之RCE
  • 最大不相交区间数量
  • Oracle给表空间添加容量
  • 2023年大数据与区块链国际会议 | EI、Scoups检索
  • 【洛谷算法题】P1000-超级玛丽游戏【入门1顺序结构】
  • ubuntu or kylinos软件安装错误的终极解决方案
  • 30分钟Python自动化从入门到实战(一)
  • FOC之SVPWM学习笔记
  • DSO 系列文章(3)——DSO后端正规方程构造与Schur消元
  • php 使用ES
  • 距离我成为炎帝的一次(比较近的一次)
  • Protobuf在IDEA中的插件安装教程
  • 中间件(上)
  • Python快速检验数据分布
  • uniapp微信小程序点击右上角菜单分享功能权限配置
  • 【OpenVINOSharp】在英特尔® 开发者套件爱克斯开发板使用OpenVinoSharp部署Yolov8模型