本地搭建start.spring.io

 

 内网或者网络不好的时候就无法使用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完整配置文件

 

posted @ 2021-04-25 10:57  程序猿网友666  阅读(3042)  评论(4编辑  收藏  举报