{"id":8896,"date":"2022-11-30T21:46:05","date_gmt":"2022-11-30T13:46:05","guid":{"rendered":"http:\/\/123.57.164.21\/?p=8896"},"modified":"2022-11-30T21:46:25","modified_gmt":"2022-11-30T13:46:25","slug":"spring-boot-%e9%a1%b9%e7%9b%ae-mvn-clean-install-%e6%8a%a5-unable-to-find-main-class","status":"publish","type":"post","link":"https:\/\/92it.top\/?p=8896","title":{"rendered":"Spring boot \u9879\u76ee mvn clean install \u62a5 &#8220;Unable to find main class&#8221;"},"content":{"rendered":"\n<ol><li><strong>Unable to find main class<\/strong><\/li><\/ol>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p>\u6700\u8fd1\u5728\u505a\u9879\u76ee\uff0c\u4f7f\u7528\u662fspring boot\u3002\u505a\u4e86\u4e00\u6bb5\u65f6\u95f4\u60f3\u6253\u5305\u653e\u5230\u670d\u52a1\u5668\u4e0a\u770b\u770b\u6548\u679c\u3002\u4e8e\u662f\u4f7f\u7528maven\u547d\u4ee4\u8fdb\u884c\u6253\u5305\u3002<\/p>\n\n\n\n<p>\u51fa\u73b0\u4e86\u4e0b\u9762\u7684\u9519\u8bef\u3002<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">&nbsp;Unable to find main class<\/pre>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/123.57.164.21\/wp-content\/uploads\/2022\/11\/\u56fe\u7247-357-1024x164.png\" alt=\"\" class=\"wp-image-8898\" width=\"565\" height=\"90\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2022\/11\/\u56fe\u7247-357-1024x164.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2022\/11\/\u56fe\u7247-357-300x48.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2022\/11\/\u56fe\u7247-357-768x123.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2022\/11\/\u56fe\u7247-357-1536x246.png 1536w, https:\/\/92it.top\/wp-content\/uploads\/2022\/11\/\u56fe\u7247-357-830x133.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2022\/11\/\u56fe\u7247-357-230x37.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2022\/11\/\u56fe\u7247-357-350x56.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2022\/11\/\u56fe\u7247-357-480x77.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2022\/11\/\u56fe\u7247-357.png 1608w\" sizes=\"(max-width: 565px) 100vw, 565px\" \/><\/figure><\/div>\n\n\n\n<p>\u539f\u6765spring boot\u9879\u76ee\u4f7f\u7528maven\u6253\u5305\uff0c\u5982\u679c\u6ca1\u6709\u505a\u914d\u7f6e\u7684\u8bdd\uff0c\u4f1a\u81ea\u52a8\u5bfb\u627e\u7b7e\u540d\u662fpublic static void main(String[] args)\u7684\u65b9\u6cd5\u3002<\/p>\n\n\n\n<p>\u68c0\u67e5\u9879\u76ee\u4e2d\u662f\u5426\u6709main\u65b9\u6cd5\u5e76\u4e14main\u65b9\u6cd5\u4e0a\u662f\u5426\u6709 <code>@SpringBootApplication<\/code> \u6ce8\u89e3\u3002<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">mvn \u4f1a\u81ea\u52a8\u5728\u9879\u76ee\u4e2d\u627emain\u65b9\u6cd5\u52a0\u5165\u5230jar\u4e2d\u7684\u4e3b\u6e05\u5355\u5c5e\u6027\u4e2d\u3002\n\u5982\u679c\u6ca1\u6709\u6ca1\u6709\u627e\u5230main\u65b9\u6cd5,\u5f53\u4f60\u6253\u5305\u7684\u65f6\u5019\u5c31\u4f1a\u62a5\u9519  \"Unable to find main class\"\u3002<\/pre>\n\n\n\n<p><strong>2.Unable to find a single main class<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p>\u5f53\u9879\u76ee\u4e2d\u591a\u4e2aclass\u5b58\u5728main\u65b9\u6cd5\uff0c\u7ed3\u679c\u63d0\u793a\u53e6\u5916\u7684\u9519\u8bef\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">&nbsp;Unable to find a single main class<\/pre>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/123.57.164.21\/wp-content\/uploads\/2022\/11\/\u56fe\u7247-358-1024x198.png\" alt=\"\" class=\"wp-image-8900\" width=\"561\" height=\"108\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2022\/11\/\u56fe\u7247-358-1024x198.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2022\/11\/\u56fe\u7247-358-300x58.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2022\/11\/\u56fe\u7247-358-768x148.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2022\/11\/\u56fe\u7247-358-1536x297.png 1536w, https:\/\/92it.top\/wp-content\/uploads\/2022\/11\/\u56fe\u7247-358-830x160.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2022\/11\/\u56fe\u7247-358-230x44.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2022\/11\/\u56fe\u7247-358-350x68.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2022\/11\/\u56fe\u7247-358-480x93.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2022\/11\/\u56fe\u7247-358.png 1614w\" sizes=\"(max-width: 561px) 100vw, 561px\" \/><\/figure><\/div>\n\n\n\n<p>\u68c0\u67e5\u9879\u76ee\u4e2d\u662f\u5426\u6709\u591a\u4e2amain\u65b9\u6cd5<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">\u5982\u679c\u9879\u76ee\u4e2d\u5b58\u5728\u591a\u4e2amain\u65b9\u6cd5,mvn\u4f1a\u4e0d\u77e5\u9053\u4f60\u7a76\u7adf\u60f3\u8981\u7528\u54ea\u4e2amain\u65b9\u6cd5\u4f5c\u4e3ajar\u5305\u7684\u6e05\u5355\u5c5e\u6027\n\u6240\u4ee5\u8fd9\u4e2a\u65f6\u5019\u4f60\u5fc5\u987b\u8981\u5728pom.xml\u6587\u4ef6\u4e2d\u6307\u5b9a\u4e00\u4e2a mainClass \n<\/pre>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\u5982\u679c\u9879\u76ee\u4e2d\u5b58\u5728\u591a\u4e2amain\u65b9\u6cd5,mvn\u4f1a\u4e0d\u77e5\u9053\u4f60\u7a76\u7adf\u60f3\u8981\u7528\u54ea\u4e2amain\u65b9\u6cd5\u4f5c\u4e3ajar\u5305\u7684\u6e05\u5355\u5c5e\u6027\n\u6240\u4ee5\u8fd9\u4e2a\u65f6\u5019\u4f60\u5fc5\u987b\u8981\u5728pom.xml\u6587\u4ef6\u4e2d\u6307\u5b9a\u4e00\u4e2a mainClass \n&lt;build>\n    &lt;plugins>\n        &lt;plugin>\n            &lt;groupId>org.springframework.boot&lt;\/groupId>\n            &lt;artifactId>spring-boot-maven-plugin&lt;\/artifactId>\n            &lt;configuration>\n                &lt;mainClass>com.**.**.testApplication&lt;\/mainClass>\n            &lt;\/configuration>\n        &lt;\/plugin>\n    &lt;\/plugins>\n&lt;\/build><\/pre>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">mvn \u4e4b\u6240\u4ee5\u80fd\u627e\u5230\u9879\u76ee\u4e2d\u7684main\u65b9\u6cd5\uff0c\u662f\u56e0\u4e3amvn\u6709\u4e00\u5957\u81ea\u5df1\u7684\u9879\u76ee\u7ed3\u6784\n\u4f8b\u5982\uff1a\nsource (\u6e90\u7801) \u76ee\u5f55:\n      \/src\/main\/java\nresources (\u6240\u9700\u8d44\u6e90) \u76ee\u5f55:\n     \/src\/main\/resources\n\u6240\u4ee5\u9700\u8981\u68c0\u67e5\u6211\u4eec\u7684\u9879\u76ee\u7ed3\u6784\u662f\u5426\u662f\u6309\u7167maven\u7684\u9ed8\u8ba4\u9879\u76ee\u7ed3\u6784\u7684\u6807\u51c6\n\u5728IDEA\u4e2d,\u5982\u679c\u9879\u76ee\u7ed3\u6784\u4e0d\u662f\u8fd9\u79cd\u9ed8\u8ba4\u7684\u7ed3\u6784\u7684\u8bdd,\u6211\u4eec\u9700\u8981\u5728IDEA\u4e2d\u6307\u5b9asource\u6216resources\u76ee\u5f55\n\u5982\u679c\u5df2\u7ecf\u6309\u7167\u8fd9\u79cd\u9ed8\u8ba4\u9879\u76ee\u7ed3\u6784\u7684\u6807\u51c6\u5bfc\u5165IDEA\u662f\u4e0d\u9700\u8981\u624b\u52a8\u6307\u5b9asource\u7684\n\u540c\u7406\uff0c\u5982\u679c\u4e0d\u6309\u7167\u8fd9\u79cd\u9ed8\u8ba4\u6807\u51c6\u521b\u5efa\u9879\u76eemvn\u9ed8\u8ba4\u4e5f\u4e0d\u8ba4\u8bc6\u9879\u76ee\u4e2d\u7684source\n\u6240\u4ee5\u6211\u4eec\u4e5f\u53ef\u4ee5\u901a\u8fc7\u5982\u4e0b\u914d\u7f6e\u6307\u5b9asource\u548cresource\u76ee\u5f55\n&lt;build>\n   &lt;sourceDirectory>${project.basedir}\/src\/main\/java&lt;\/sourceDirectory>\n   &lt;resources>\n      &lt;resource>\n        &lt;directory>${project.basedir}\/src\/main\/resources&lt;\/directory>\n      &lt;\/resource>\n    &lt;\/resources>\n    &lt;plugins>\n        &lt;plugin>\n            &lt;groupId>org.springframework.boot&lt;\/groupId>\n            &lt;artifactId>spring-boot-maven-plugin&lt;\/artifactId>\n            &lt;configuration>\n                &lt;mainClass>com.**.**.testApplication&lt;\/mainClass>\n            &lt;\/configuration>\n        &lt;\/plugin>\n    &lt;\/plugins>\n&lt;\/build>\n\u4f46\u662f\u4e0d\u63a8\u8350\u4fee\u6539\u9ed8\u8ba4\u7684\u9879\u76ee\u7ed3\u6784\uff0c\u8fd8\u662f\u63a8\u8350\u4f7f\u7528maven\u63d0\u4f9b\u7684\u9ed8\u8ba4\u9879\u76ee\u7ed3\u6784\u6765\u521b\u5efa\u9879\u76ee<\/pre>\n\n\n\n<p><strong>3.Maven\u591a\u6a21\u5757\u6253\u5305\u9047\u5230\u7684\u95ee\u9898<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p>\u591a\u6a21\u5757\u6253\u5305\u65f6\uff0c\u5b50\u6a21\u5757\u63d0\u793a\u627e\u4e0d\u5230<strong>main class<\/strong>\uff0c\u6709\u4eba\u8bf4\u76f4\u63a5\u5728\u5b50\u6a21\u5757\u52a0\u4e0amainclass\u5c31\u597d\u4e86\uff0c\u53ef\u662f\u5f80\u5f80\u6253\u7684\u662fdao\u5c42\u7684\u5305\uff0c\u4ed6\u5c31\u662f\u4e00\u4e2ajar\uff0c\u4e0d\u662f\u4e00\u4e2a\u53ef\u6267\u884c\u7a0b\u5e8f\uff0c\u672c\u6765\u5c31\u6ca1\u6709\u5165\u53e3class\u3002\u90a3\u8be5\u5982\u4f55\u8bbe\u7f6e\u5462\uff1f<\/p>\n\n\n\n<p>\u5176\u5b9e\u5f88\u7b80\u5355\uff0c\u53ea\u9700\u8981\u5728\u5b50\u6a21\u5757\u4e2d\u6dfb\u52a0\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;plugin>\n\t            &lt;groupId>org.springframework.boot&lt;\/groupId>\n\t            &lt;artifactId>spring-boot-maven-plugin&lt;\/artifactId>\n\t            &lt;configuration>\n\t                &lt;skip>true&lt;\/skip>\n\t            &lt;\/configuration>\n&lt;\/plugin><\/pre>\n\n\n\n<p>\u914d\u7f6e\u6dfb\u52a0\uff0c\u8bbe\u7f6e\u8fc7\u6ee4\u5373\u53ef\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Unable to find main class \u6700\u8fd1\u5728\u505a\u9879\u76ee\uff0c\u4f7f\u7528\u662fspring boot\u3002\u505a\u4e86\u4e00\u6bb5\u65f6\u95f4\u60f3 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[26],"tags":[],"_links":{"self":[{"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts\/8896"}],"collection":[{"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=8896"}],"version-history":[{"count":8,"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts\/8896\/revisions"}],"predecessor-version":[{"id":8906,"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts\/8896\/revisions\/8906"}],"wp:attachment":[{"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=8896"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=8896"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=8896"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}