当前位置: 首页 > 新闻中心 > 使用eclipse创建springboot项目(从零开始配置)

使用eclipse创建springboot项目(从零开始配置)

发布时间:2024-03-27 10:16:10

  1. spring boot在eclipse中怎么用?
  2. eclipse中springboot项目创建后没有pom.xml文件
  3. 用eclipse的sts插件构建springboot项目时一直报错怎么办?

一、spring boot在eclipse中怎么用?

方法步骤:

1.创建项目,选择spring starter project。填写跟项目相关的各种信息,然后next:

2.选择需要的dependency,然后next:

3.最后"finish",就开始下载jar包了,这个过程需要的时间比较长。

4.运行:右键project –> run as –> maven build –> 在goals里输入spring-boot:run ,然后apply,最后点击run。打包执行命令:clean package

二、eclipse中springboot项目创建后没有pom.xml文件

eclipse 创建spring boot项目以及出现警告:pom.xml不存在的解决办法

step 1: file=>new=>project=>spring starter project

step 2: 填写项目基本信息

step 3:选择需要引用的功能包

此处选择lombok与spring data jpa

step 4:项目创建完,基本结构如下:

此处pom.xml前面有个错误。

右键项目=>run as maven build,出现如下错误信息

右键项目=>maven=>update project

[warning] the requested profile "pom.xml" could not be activated because it does not exist.

解决办法: 参考原文链接:https://blog.csdn.net/hills/article/details/118525257

因为eclipse插件不兼容的原因,加上当前spring boot工程默认是jar导出,所以需要在你的pom.xml加上以下配置项:

<properties>

<maven-jar-plugin.version>3.0.0</maven-jar-plugin.version>

</properties>

上述代码中“3.0.0”需要你以实际的版本号为准。

最后,右键项目=>maven=>update project...后,此报错消失。

这个插件的作用是,比如:利用maven打jar时,设定manifest的参数,比如指定运行的main class入口类,以及将依赖的jar包加入到classpath中等。

三、用eclipse的sts插件构建springboot项目时一直报错怎么办?

产生该问题的原因是eclipse与sts版本不匹配。

我的eclipse版本是mars release (4.5.0)装下面这个版本是正常的。

建议:本地安装试试,参考:http://www.cnblogs.com/kwony/p/7079779.html

中(2)本地安装。例如:在http://spring.io/tools/sts/all/ 。

下载好springsource-tool-suite-3.9.0.release-e4.6.3-updatesite.zip文件。

eclipse菜单help--install new software--add--archive选择zip文件,即可安装。