Because https://start.spring.io/ is unstable in domestic access, it often causes connection timeouts. So I came up with the idea of building my own Spring Initializr server.
Here are some pit climbing records from the time of construction:
// JDK, git, and Maven must be installed on the server in advance
yum install java-1.8. 0-openjdk*
yum install git
// Download the Maven package and upload it
tar xvzf apache-maven-3.61.-bin.tar.gz
Copy the code
After configuring environment variables and other information, start setting up the Spring Initializr server
First to clone the source code
git clone https://github.com/spring-io/start.spring.io.git
Copy the code
Go to the clone code directory and package it locally via Maven
// Go to start.spring. IO
cd start.spring.io
// Package to a local directory
mvn clean install
Copy the code
Pit one: Spring. initializr dependency
Error message: the Failure to find IO. Spring. Initializr: initializr - bom: pom:0.10. 0-SNAPSHOT
...
Copy the code
According to the error information, it is obvious that some dependent packages are not downloaded and imported normally, resulting in the dependency cannot find the corresponding JAR package. After a search, found the package from https://github.com/spring-io/initializr package in the warehouse, we only need to clone project down and then execute MVN clean install – DskipTests commands to the local installation.
// Clone code
git clone https://github.com/spring-io/initializr.git
// Verify that the cloned code version is the missing 0.10.0-snapshot (refer to the pm.xml file configuration)
// Go to the directory of the clone code and run the maven installation command
cd initializr
mvn clean install -DskipTests
Copy the code
The installation is successful if the following information is displayed:
Go back to the start.spring. IO code directory and continue with the Maven installation command
// Go to start.spring. IO
cd start.spring.io
// Run the maven installation command without skipping the test
mvn clean install
Copy the code
Pit crawl 2: Start-client dependency
We still get an error because the start-client module relies on Nodejs to perform the build, and I don’t have it installed on my server, so I continue to install Nodejs
// First add Nodejs 14.x repository (root)
curl -sL https://rpm.nodesource.com/setup_14.x | bash -
// Start installing Nodejs
yum -y install nodejs
// Install gcc-C ++ to build native plug-ins from NPM
yum install gcc-c++ make
// Check whether node and NPM are installed successfully
node --version / / v14.15.4
npm --version / / 6.14.10
Copy the code
After the installation, run the MVN clean install command to install start.spring. IO successfully
Go to the compile output directory of website target and start start-site-exec.jar
cd ./start-site/target
/ / start the start - site - exec. Jar
java -jar start-site-exec.jar
Copy the code
After successful startup, access localhost:8080
The Spring Initializr page is displayed normally, and the setup is successful. Finally, the start-site-exec.jar can be hung in the server background and run normally
// Use nohup & background run
nohup java -jar start-site-exec.jar >output.log 2> &1 &
Copy the code
— 完 —