內網或者網絡不好的時候就無法使用start.spring.io 新建springboot項目了,所有就自己搭建本地的服務器吧。
-
使用git cloen代碼:git clone https://github.com/spring-io/start.spring.io.git
-
打包編譯:cd start.spring.io ,執行./mvnw clean package -Dmaven.test.skip=true
-
進入start-site\target目錄下兩個jar包 用start-site-exec.jar可以, 使用java -jar -Dserver.port=8080 start-site-exec.jar 運行
-
IDEA之中,使用Custom,填入localhost:8080然后創建項目
遇到的問題及解決辦法:
ERROR1:
[ERROR] Failed to execute goal io.spring.javaformat:spring-javaformat-maven-plugin:0.0.26:validate (default) on project start-site: Formatting violations found in the following files:
[INFO] start.spring.io .................................... SUCCESS [ 4.016 s] [INFO] start.spring.io client ............................. SUCCESS [02:43 min] [INFO] start.spring.io website ............................ FAILURE [ 12.280 s] [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 03:01 min [INFO] Finished at: 2021-04-23T16:39:46+08:00 [INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal io.spring.javaformat:spring-javaformat-maven-plugin:0.0.26:validate (default) on project start-site: Formatting violations found in the following files: [ERROR] * D:\start.spring.io\start-site\src\main\java\io\spring\start\site\extension\build\gradle\GradleBuildSystemHelpDocumentCustomizer.java [ERROR] * D:\start.spring.io\start-site\src\main\java\io\spring\start\site\extension\build\gradle\GradleProjectGenerationConfiguration.java ...... ...... [ERROR] * D:\start.spring.io\start-site\src\test\java\io\spring\start\site\support\implicit\ImplicitDependencyTests.java [ERROR] * D:\start.spring.io\start-site\src\test\java\io\spring\start\site\support\StartInitializrMetadataUpdateStrategyTests.java [ERROR] [ERROR] Run `spring-javaformat:apply` to fix. [ERROR] -> [Help 1] [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. [ERROR] Re-run Maven using the -X switch to enable full debug logging. [ERROR] [ERROR] For more information about the errors and possible solutions, please read the following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException [ERROR] [ERROR] After correcting the problems, you can resume the build with the command [ERROR] mvn <args> -rf :start-site
解決辦法:
很明顯了,仔細看一下錯誤信息就能解決!! 其實最后給了解決辦法了“ Run `spring-javaformat:apply` to fix. ”!
因為這個工程使用的是mvnw ,所以運行一下命令解決此問題。
$ ./mvnw spring-javaformat:apply
ERROR2:
maven git插件找不到.git目錄的問題!!
[ERROR] Failed to execute goal pl.project13.maven:git-commit-id-plugin:3.0.1:revision (default) on project start-site: .git directory is not found! Please specify a valid [dotGitDirectory] in your pom.xml -> [Help 1]
錯誤詳細:
[INFO] ------------------------------------------------------------------------ [INFO] Reactor Summary for start.spring.io 0.0.1-SNAPSHOT: [INFO] [INFO] start.spring.io .................................... SUCCESS [ 3.527 s] [INFO] start.spring.io client ............................. SUCCESS [ 53.677 s] [INFO] start.spring.io website ............................ FAILURE [ 27.601 s] [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 01:26 min [INFO] Finished at: 2021-04-23T17:03:42+08:00 [INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal pl.project13.maven:git-commit-id-plugin:3.0.1:revision (default) on project start-site: .git directory is not found! Please specify a valid [dotGitDirectory] in your pom.xml -> [Help 1] [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. [ERROR] Re-run Maven using the -X switch to enable full debug logging. [ERROR] [ERROR] For more information about the errors and possible solutions, please read the following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException [ERROR] [ERROR] After correcting the problems, you can resume the build with the command [ERROR] mvn <args> -rf :start-site
解決辦法:
不知道在github上下載的官方源碼為啥會有問題!!既然錯誤信息里說了“未找到git目錄!” ,那解決辦法有兩種:1,給他配置目錄 2,跳過執行該目標; 建議新手小白使用第二種,,,我就是使用第二種,,,言歸正傳,第二種解決辦法如下:
找到你想項目-> github源碼根目錄\start-site\pom.xml -->編輯此文件 -->搜索“git-commit-id-plugin” -->新增以下北京黃色部分代碼
<plugin>
<groupId>pl.project13.maven</groupId>
<artifactId>git-commit-id-plugin</artifactId>
<configuration>
<!--".git"文件夾未找到時,構建是否失敗;若設置true,則構建失敗;若設置false,則跳過執行該目標;默認值:true;-->
<failOnNoGitDirectory>false</failOnNoGitDirectory>
</configuration>
</plugin>
參考資料:
https://blog.csdn.net/wangjunjun2008/article/details/10526151
https://www.it1352.com/802011.html
知識擴展:
1.使用./mvnw ** 命令下載資源太慢??
解決辦法:
首先你的明白mvnw跟mvn命令的區別,推薦看下這篇博客:https://blog.csdn.net/Fishandbearspaw/article/details/104637284/ 簡單明了 適合新手!
看完博客之后呢??我們去修改他的這個命令maven的配置文件:
C:\Users\登錄名\.m2\wrapper\dists\apache-maven-你的版本號-bin\1iopthnavndlasol9gbrbg6bf2\apache-maven-你的版本號\conf\settings.xml
例如我的:
C:\Users\Administrator\.m2\wrapper\dists\apache-maven-3.6.3-bin\1iopthnavndlasol9gbrbg6bf2\apache-maven-3.6.3\conf\settings.xml
其實就是修改mirrors 指定去aliyun下載!!
maven settings.xml完整配置文件
