Build a local SpringBoot Initializr application

It is very convenient to use the initializr function to build the project environment

principle

The principle is to check the required dependencies on the Idea panel and send a request to the application server. The server returns a compressed package of the pom file generated according to the requirements. Idea builds the project through the pom file in the compressed package, https://start.spring. io/ is an application in itself.

question

However, using https://start.spring.io/ to deploy overseas, it is often very strange that the access is slow and cannot be accessed, or you can enter the dependency selection interface but cannot receive the compressed package and report various exceptions. If you still want to use the original initializr, you can Use the source code provided by spring to build it yourself, and deploy it locally or on a cloud server

required environment

  • git
  • maven3.5+ (remote warehouse configuration Alibaba Cloud)
  • jdk17.0 (official recommendation)
# 拉取项目源码 , github连接问题, 有可能要多试上几次
$ git clone https://github.com/spring-io/start.spring.io.git

# 进入项目目录
$ cd start.spring.io/

# 打包项目 (如出现失败,参见下面我踩过的坑)
$ mvn clean install -DskipTests

# 进入 start-site目录
$ cd start-site

# 在本地启动该项目(不推荐)
$ mvn spring-boot:run

# 进入\start.spring.io\start-site
$  cd  项目路径\start.spring.io\start-site\target

# 找到  start-site-exec.jar , 把它在云服务器或者本地启动就OK了
nohup java -jar  start-site-exec.jar &

# 访问项目
本地 :  localhost:8080
云服务器:  ip:8080

problems encountered

This application pops up during the packaging process and cannot run on your computer , and the packaging fails.
insert image description here
Solution: After n attempts, it is found that the problem is that the node.exe installation package that comes with the project does not match the current environment

  • Download node.exe for 64-bit v12.13.0 Download: (https://nodejs.org/dist/v12.13.0/win-x64/node.exe)

  • Enter the directory where node.exe is located (project\start.spring.io\start-client\node) Replace the original node.exe with the downloaded node.exe

  • Re-mvn clean install -DskipTests The pop-up dialog box just now does not exist, the packaging is successful, and the jar package can be obtained.

insert image description here

Guess you like

Origin blog.csdn.net/weixin_48011779/article/details/125232846