mvn spring-boot:run出錯No plugin found for prefix 'spring-boot'
阿新 • • 發佈:2019-01-04
使用 SpringLoader 進行專案的熱部署
以 maven 外掛方式使用 SpringLoader
在 pom 檔案中新增外掛配置檔案中新增外掛配置
使用 maven 的命令spring-boot:run來啟動::
首先執行Spring-boot的啟動類,且不能停止它啟動,然後在專案名上滑鼠右鍵單擊,選擇run as->maven build(第二個)->在goals框中輸入spring-boot:run命令,點選run按鈕,啟動springLoader時發生以下錯誤:
[ERROR] No plugin found for prefix 'spring-boot' in the current project and in t he plugin groups [org.apache.maven.plugins, org.codehaus.mojo] available from th e repositories [local (C:\Users\Administrator\.m2\repository), alimaven (http:// maven.aliyun.com/nexus/content/groups/public/)] -> [Help 1] [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e swit ch. [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 rea d the following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/NoPluginFoundF orPrefixException。
錯誤的意思就是:
意思就是說沒有spring-boot-maven-plugin,去本地倉庫檢視一下,只有兩個.lastUpdated檔案,說明jar包沒有下載成功,再去maven的遠端倉庫看一下,發現沒有spring-boot-maven-plugin。
解決方法:
在https://mvnrepository.com網站上重新下載jar包。在搜尋框中輸入spring-boot-maven-plugin,springloaded即可找到對應的jar包
重新執行,又出現spring-boot-maven-plugin版本號的問題
問題原因:spring-boot-maven-plugin的版本號必須和springloaded的一致,重新下載版本號一致的jar包,重新執行,問題解決,最終pom.xml程式碼如下:
<!-- springloader 外掛 --> <build> <plugins> <plugin> <!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-maven-plugin --> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <version>1.2.5.RELEASE</version> <dependencies> <dependency> <groupId>org.springframework</groupId> <artifactId>springloaded</artifactId> <version>1.2.5.RELEASE</version> </dependency> </dependencies> </plugin> </plugins> </build>
最後執行成功就是這樣的:
[INFO] Downloaded from nexus-aliyun: http://maven.aliyun.com/nexus/content/groups/public/org/vafer/jdependency/0.7/jdependency-0.7.jar (12 kB at 1.0 kB/s)
[INFO] Downloaded from nexus-aliyun: http://maven.aliyun.com/nexus/content/groups/public/org/apache/maven/plugins/maven-shade-plugin/2.2/maven-shade-plugin-2.2.jar (100 kB at 8.7 kB/s)
[INFO] Downloaded from nexus-aliyun: http://maven.aliyun.com/nexus/content/groups/public/com/google/guava/guava/11.0.2/guava-11.0.2.jar (1.6 MB at 110 kB/s)
[INFO] Attaching agents: [D:\maven\repository\org\springframework\springloaded\1.2.5.RELEASE\springloaded-1.2.5.RELEASE.jar]
Exception in thread "main" java.lang.NoClassDefFoundError: org/springframework/boot/SpringApplication
at com.itlaobing.App.main(App.java:10)
Caused by: java.lang.ClassNotFoundException: org.springframework.boot.SpringApplication
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 1 more
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 39.812 s
[INFO] Finished at: 2019-01-04T11:22:21+08:00
[INFO] ------------------------------------------------------------------------