公司中的项目了使用微服务架构,使用springcloud以及它集成的一些相关项目,因此虽然在其他方面的很多技术上还感觉急需提高,却又不得不以工作为重,先放下其他来了解一下这方面的技术。

其实spring cloud是建立在spring boot的基础上的,我之前也学过spring boot,所以一切还算轻车熟路吧。

spring boot的理念是“习惯优于配置”,我个人的理解就是尽量减少开发过程中手动的spring相关的配置文件。同时使用spring boot还有一个优点就是,它可以内嵌很多容器,例如tomcat,使得原本可能需要安装tomcat才能运行的web项目,可以直接以运行jar文件的形式启动运行。

spring boot项目创建有多种方式,鉴于目前工作中使用的是eclipse开发工具,因此整个学习过程中,也都是在eclipse中进行。

而eclipse中的创建实际上也是可以有两种方式的,一种是在安装了STS插件之后直接创建,另一种是创建简单的maven项目后,修改pom.xml文件,为了提高效率,我这里就安装了STS插件,以第一种方式创建。


一 :安装eclipse插件

Help->Eclipse Marketplace->

在Eclipse中搭建Spring boot项目


Search中查找"Spring Tool Suite (STS) for Eclipse"点击intall安装

在Eclipse中搭建Spring boot项目

在Eclipse中搭建Spring boot项目

  这里注意选择"I accept the..."

在Eclipse中搭建Spring boot项目

在Eclipse中搭建Spring boot项目

之后会下载插件,国内下载慢很正常,建议开启科学上网

下载完成后重启eclipse会比较慢,稍等几分钟

在Eclipse中搭建Spring boot项目

二:创建项目

在Eclipse中搭建Spring boot项目

在Eclipse中搭建Spring boot项目

在Eclipse中搭建Spring boot项目

在Eclipse中搭建Spring boot项目



在Eclipse中搭建Spring boot项目

三:启动项目


如果项目出现爆红的情况,可以按照下面的做法升级eclipse ,如果没有问题侧进行最后一步启动项目即可。

详细情况:

Eclipse Maven pom报错:

org.apache.maven.archiver.MavenArchiver.getManifest(org.apache.maven.project.MavenProject, org.apache.maven.archiver.MavenArchiveConfiguration) pom.xml / line 1 Maven Configuration Problem

解决方法:

  1. 简单办法:将maven-jar-plugin 版本降级至 2.6 或以下

  2. 推荐办法:升级m2eclipse插件版本

下面为操作步骤:

在Eclipse中搭建Spring boot项目

在Eclipse中搭建Spring boot项目

在Eclipse中搭建Spring boot项目

MavenArchiver

https://otto.takari.io/content/sites/m2e.extras/m2eclipse-mavenarchiver/0.17.2/N/LATEST/

 如果上面的链接用不了可以用这个:

http://repo1.maven.org/maven2/.m2e/connectors/m2eclipse-mavenarchiver/0.17.2/N/LATEST/


在Eclipse中搭建Spring boot项目

在Eclipse中搭建Spring boot项目

在Eclipse中搭建Spring boot项目在Eclipse中搭建Spring boot项目
在Eclipse中搭建Spring boot项目

相关文章:

  • 2021-07-16
  • 2021-07-11
  • 2021-11-22
  • 2021-12-19
  • 2021-10-12
猜你喜欢
  • 2021-11-08
  • 2021-07-30
  • 2021-11-14
  • 2021-12-22
  • 2021-09-17
  • 2022-12-23
  • 2021-06-01
相关资源
相似解决方案