活久見: maven pom 居然都會崩潰!

問題是: 個人應用的pom 並無任何報錯,可是代碼報錯,並且編譯不經過。html

 

以下,我本地項目,從 spring-cloud-alibaba-dependencies 0.2.1.RELEASE 升級到 0.2.2.RELEASE: java

            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-dependencies</artifactId>
                <version>Finchley.SR1</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>

            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-alibaba-dependencies</artifactId>
                <version>0.2.2.RELEASE</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>

就出現了類找不到的狀況 cannot resolve symbol "xxx" ,好比這個:spring

import org.springframework.cloud.client.discovery.EnableDiscoveryClient;    < --- cannot resolve symbol "xxx" apache

EnableDiscoveryClient 是spring-cloud-commons jar 的內容, 而spring-cloud-commons 是dubbo-registry-nacos,spring-cloud-starter-alibaba-nacos-config 和 spring-cloud-starter-alibaba-nacos-discovery的 依賴。app

 

spring cloud 相關的類/接口 彷佛都不能用了, 可是以前都是好好的啊! 查看maven 的dependencies 圖發現, 某些 jar 彷佛缺乏沒有被依賴儘可能。 不是某幾個, 而是不少的。。。dom

彷佛某些 dependency 被切斷了。。 因而手動添加了幾個 dependency 並寫上了版本號,要是不寫版本號, 那麼問題依舊。 難道須要一個個的處理問題?maven

 

以前都不須要手動加入的dependency, 如今一個個手動添加, 也太麻煩了吧!ide

觀察發現dubbo-registry-nacos-0.0.2.pom 彷佛不對, 裏面怎麼全是NUL 這種黑色字符,經驗告訴我,這個是文件格式不對或者編碼格式問題, 也多是文件沒有正確結尾,或者是被修改了/截斷了.. 怎麼辦? 這個版本的dubbo-registry-nacos-0.0.2 就是這樣的? 查看了同事的這個dubbo-registry-nacos-0.0.2.pom 文件,發現沒有這個問題! 刪除從新下載吧!(同一個目錄下的其餘文件 包括jar 也一併所有刪除) 就行了 ! 從新下載後pom 是正常了,可是問題依舊。ui

經驗告訴我,maven 出了問題了, clean 一下吧:this

E:\dev\erdp2\erdp_discuss>mvn clean package
[INFO] Scanning for projects...
[WARNING]
[WARNING] Some problems were encountered while building the effective model for com.lkk:erdp_discuss_app:war:2.0.0-SNAPSHOT
[WARNING] 'dependencies.dependency.(groupId:artifactId:type:classifier)' must be unique: com.fasterxml.jackson.core:jackson-core:jar -> duplicate declaration of version (?) @ line 141, column 21
[WARNING] 'dependencies.dependency.(groupId:artifactId:type:classifier)' must be unique: com.fasterxml.jackson.core:jackson-databind:jar -> duplicate declaration of version (?) @ line 145, column 21
[WARNING] 'dependencies.dependency.(groupId:artifactId:type:classifier)' must be unique: com.fasterxml.jackson.core:jackson-annotations:jar -> duplicate declaration of version (?) @ line 149, column 21
[WARNING]
[WARNING] Some problems were encountered while building the effective model for com.lkk:erdp_discuss_controller:jar:2.0.0-SNAPSHOT
[WARNING] 'dependencies.dependency.(groupId:artifactId:type:classifier)' must be unique: com.lkk:erdp_plan_domain:jar -> duplicate declaration of version (?) @ line 86, column 21
[WARNING]
[WARNING] Some problems were encountered while building the effective model for com.lkk:erdp_discuss_service:jar:2.0.0-SNAPSHOT
[WARNING] 'dependencies.dependency.(groupId:artifactId:type:classifier)' must be unique: com.lkk:erdp_system_domain:jar -> duplicate declaration of version (?) @ line 48, column 21
[WARNING]
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING]
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING]
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO]
[INFO] erdp_discuss                                                       [pom]
[INFO] erdp_discuss_controller                                            [jar]
[INFO] erdp_discuss_service                                               [jar]
[INFO] ppm_discuss_app                                                    [war]
[INFO]
[INFO] -----------------------< com.lkk:erdp_discuss >-----------------------
[INFO] Building erdp_discuss 2.0.0-SNAPSHOT                               [1/4]
[INFO] --------------------------------[ pom ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:3.0.0:clean (default-clean) @ erdp_discuss ---
[INFO]
[INFO] -----------------< com.lkk:erdp_discuss_controller >------------------
[INFO] Building erdp_discuss_controller 2.0.0-SNAPSHOT                    [2/4]
[INFO] --------------------------------[ jar ]---------------------------------
[WARNING] The POM for com.alibaba:dubbo:jar:2.8.4 is missing, no dependency information available
[INFO]
[INFO] --- maven-clean-plugin:3.0.0:clean (default-clean) @ erdp_discuss_controller ---
[INFO] Deleting E:\dev\erdp2\erdp_discuss\erdp_discuss_controller\target
[INFO]
[INFO] --- maven-resources-plugin:3.0.1:resources (default-resources) @ erdp_discuss_controller ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.5:compile (default-compile) @ erdp_discuss_controller ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 2 source files to E:\dev\erdp2\erdp_discuss\erdp_discuss_controller\target\classes
[INFO]
[INFO] --- maven-resources-plugin:3.0.1:testResources (default-testResources) @ erdp_discuss_controller ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 5 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.5:testCompile (default-testCompile) @ erdp_discuss_controller ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 2 source files to E:\dev\erdp2\erdp_discuss\erdp_discuss_controller\target\test-classes
[INFO] /E:/dev/erdp2/erdp_discuss/erdp_discuss_controller/src/test/java/com/lkk/ppm/discuss/SysConsumerApplication.java: E:\dev\erdp2\erdp_discuss\erdp_discuss_controller\src\test\java\com\lkk\ppm\discuss\SysConsumerApplication.java使用或覆蓋了已過
時的 API。
[INFO] /E:/dev/erdp2/erdp_discuss/erdp_discuss_controller/src/test/java/com/lkk/ppm/discuss/SysConsumerApplication.java: 有關詳細信息, 請使用 -Xlint:deprecation 從新編譯。
[INFO]
[INFO] --- maven-surefire-plugin:2.19.1:test (default-test) @ erdp_discuss_controller ---
[INFO] Tests are skipped.
[INFO]
[INFO] --- maven-jar-plugin:3.0.2:jar (default-jar) @ erdp_discuss_controller ---
[INFO] Building jar: E:\dev\erdp2\erdp_discuss\erdp_discuss_controller\target\erdp_discuss_controller-2.0.0-SNAPSHOT.jar
[INFO]
[INFO] -------------------< com.lkk:erdp_discuss_service >-------------------
[INFO] Building erdp_discuss_service 2.0.0-SNAPSHOT                       [3/4]
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:3.0.0:clean (default-clean) @ erdp_discuss_service ---
[INFO] Deleting E:\dev\erdp2\erdp_discuss\erdp_discuss_service\target
[INFO]
[INFO] --- maven-resources-plugin:3.0.1:resources (default-resources) @ erdp_discuss_service ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory E:\dev\erdp2\erdp_discuss\erdp_discuss_service\src\main\resources
[INFO] skip non existing resourceDirectory E:\dev\erdp2\erdp_discuss\erdp_discuss_service\src\main\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.5:compile (default-compile) @ erdp_discuss_service ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 2 source files to E:\dev\erdp2\erdp_discuss\erdp_discuss_service\target\classes
[INFO]
[INFO] --- maven-resources-plugin:3.0.1:testResources (default-testResources) @ erdp_discuss_service ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 2 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.5:testCompile (default-testCompile) @ erdp_discuss_service ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 2 source files to E:\dev\erdp2\erdp_discuss\erdp_discuss_service\target\test-classes
[INFO]
[INFO] --- maven-surefire-plugin:2.19.1:test (default-test) @ erdp_discuss_service ---
[INFO] Tests are skipped.
[INFO]
[INFO] --- maven-jar-plugin:3.0.2:jar (default-jar) @ erdp_discuss_service ---
[INFO] Building jar: E:\dev\erdp2\erdp_discuss\erdp_discuss_service\target\erdp_discuss_service-2.0.0-SNAPSHOT.jar
[INFO]
[INFO] ---------------------< com.lkk:erdp_discuss_app >---------------------
[INFO] Building ppm_discuss_app 2.0.0-SNAPSHOT                            [4/4]
[INFO] --------------------------------[ war ]---------------------------------
[WARNING] The POM for org.springframework.cloud:spring-cloud-starter-alibaba-nacos-discovery:jar:0.2.2.RELEASE is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details
[WARNING] The POM for org.jboss.netty:netty:jar:3.2.5.Final is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details
[WARNING] The POM for org.springframework.cloud:spring-cloud-starter-alibaba-nacos-config:jar:0.2.2.RELEASE is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details
[INFO]
[INFO] --- maven-clean-plugin:3.0.0:clean (default-clean) @ erdp_discuss_app ---
[INFO] Deleting E:\dev\erdp2\erdp_discuss\erdp_discuss_app\target
[INFO]
[INFO] --- maven-resources-plugin:3.0.1:resources (default-resources) @ erdp_discuss_app ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 2 resources
[INFO] Copying 1 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.5:compile (default-compile) @ erdp_discuss_app ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 7 source files to E:\dev\erdp2\erdp_discuss\erdp_discuss_app\target\classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /E:/dev/erdp2/erdp_discuss/erdp_discuss_app/src/main/java/com/lkk/ppm/discuss/DiscussApplication.java:[10,50] 程序包org.springframework.cloud.client.discovery不存在
[ERROR] /E:/dev/erdp2/erdp_discuss/erdp_discuss_app/src/main/java/com/lkk/ppm/discuss/DiscussApplication.java:[28,2] 找不到符號
  符號: 類 EnableDiscoveryClient
[INFO] 2 errors
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary for erdp_discuss 2.0.0-SNAPSHOT:
[INFO]
[INFO] erdp_discuss ....................................... SUCCESS [  0.313 s]
[INFO] erdp_discuss_controller ............................ SUCCESS [  6.453 s]
[INFO] erdp_discuss_service ............................... SUCCESS [  2.553 s]
[INFO] ppm_discuss_app .................................... FAILURE [  1.628 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  11.844 s
[INFO] Finished at: 2019-05-05T15:36:09+08:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.5:compile (default-compile) on project erdp_discuss_app: Compilation failure: Compilation failure:
[ERROR] /E:/dev/erdp2/erdp_discuss/erdp_discuss_app/src/main/java/com/lkk/ppm/discuss/DiscussApplication.java:[10,50] 程序包org.springframework.cloud.client.discovery不存在
[ERROR] /E:/dev/erdp2/erdp_discuss/erdp_discuss_app/src/main/java/com/lkk/ppm/discuss/DiscussApplication.java:[28,2] 找不到符號
[ERROR]   符號: 類 EnableDiscoveryClient
[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 <goals> -rf :erdp_discuss_app

問題並不能這麼簡單的解決。可是上面的信息並不能告訴我具體什麼緣由。 經驗告訴我,經過-X 參數:

[DEBUG] =======================================================================
[WARNING] The POM for org.springframework.cloud:spring-cloud-starter-alibaba-nacos-discovery:jar:0.2.2.RELEASE is invalid, transitive dependencies (if any) will not be available: 5 problems were encountered while building the effective model for org.spr
ingframework.cloud:spring-cloud-starter-alibaba-nacos-discovery:0.2.2.RELEASE
[FATAL] Non-parseable POM C:\Users\Administrator\.m2\repository\org\springframework\cloud\spring-cloud-build-dependencies\2.0.5.RELEASE\spring-cloud-build-dependencies-2.0.5.RELEASE.pom: only whitespace content allowed before start tag and not \u0 (posi
tion: START_DOCUMENT seen \u0... @1:1)  @ C:\Users\Administrator\.m2\repository\org\springframework\cloud\spring-cloud-build-dependencies\2.0.5.RELEASE\spring-cloud-build-dependencies-2.0.5.RELEASE.pom, line 1, column 1
[FATAL] Non-parseable POM C:\Users\Administrator\.m2\repository\org\springframework\cloud\spring-cloud-openfeign-dependencies\2.0.3.RELEASE\spring-cloud-openfeign-dependencies-2.0.3.RELEASE.pom: only whitespace content allowed before start tag and not \
u0 (position: START_DOCUMENT seen \u0... @1:1)  @ C:\Users\Administrator\.m2\repository\org\springframework\cloud\spring-cloud-openfeign-dependencies\2.0.3.RELEASE\spring-cloud-openfeign-dependencies-2.0.3.RELEASE.pom, line 1, column 1
[FATAL] Non-parseable POM C:\Users\Administrator\.m2\repository\org\springframework\cloud\spring-cloud-bus-dependencies\2.0.1.RELEASE\spring-cloud-bus-dependencies-2.0.1.RELEASE.pom: only whitespace content allowed before start tag and not \u0 (position
: START_DOCUMENT seen \u0... @1:1)  @ C:\Users\Administrator\.m2\repository\org\springframework\cloud\spring-cloud-bus-dependencies\2.0.1.RELEASE\spring-cloud-bus-dependencies-2.0.1.RELEASE.pom, line 1, column 1
[FATAL] Non-parseable POM C:\Users\Administrator\.m2\repository\org\springframework\cloud\spring-cloud-gateway-dependencies\2.0.3.RELEASE\spring-cloud-gateway-dependencies-2.0.3.RELEASE.pom: only whitespace content allowed before start tag and not \u0 (
position: START_DOCUMENT seen \u0... @1:1)  @ C:\Users\Administrator\.m2\repository\org\springframework\cloud\spring-cloud-gateway-dependencies\2.0.3.RELEASE\spring-cloud-gateway-dependencies-2.0.3.RELEASE.pom, line 1, column 1
[FATAL] Non-parseable POM C:\Users\Administrator\.m2\repository\org\springframework\cloud\spring-cloud-build-dependencies\2.0.5.RELEASE\spring-cloud-build-dependencies-2.0.5.RELEASE.pom: only whitespace content allowed before start tag and not \u0 (posi
tion: START_DOCUMENT seen \u0... @1:1)  @ C:\Users\Administrator\.m2\repository\org\springframework\cloud\spring-cloud-build-dependencies\2.0.5.RELEASE\spring-cloud-build-dependencies-2.0.5.RELEASE.pom, line 1, column 1

[DEBUG] Using mirror lkk-public (http://192.168.11.200:8081/repository/lkk-public/) for maven2-repository.dev.java.net (http://download.java.net/maven/2/).
[WARNING] The POM for org.jboss.netty:netty:jar:3.2.5.Final is invalid, transitive dependencies (if any) will not be available: 1 problem was encountered while building the effective model
[FATAL] Non-parseable POM C:\Users\Administrator\.m2\repository\org\jboss\netty\netty\3.2.5.Final\netty-3.2.5.Final.pom: only whitespace content allowed before start tag and not \u0 (position: START_DOCUMENT seen \u0... @1:1)  @ line 1, column 1

[WARNING] The POM for org.springframework.cloud:spring-cloud-starter-alibaba-nacos-config:jar:0.2.2.RELEASE is invalid, transitive dependencies (if any) will not be available: 5 problems were encountered while building the effective model for org.spring
framework.cloud:spring-cloud-starter-alibaba-nacos-config:0.2.2.RELEASE
[FATAL] Non-parseable POM C:\Users\Administrator\.m2\repository\org\springframework\cloud\spring-cloud-build-dependencies\2.0.5.RELEASE\spring-cloud-build-dependencies-2.0.5.RELEASE.pom: only whitespace content allowed before start tag and not \u0 (posi
tion: START_DOCUMENT seen \u0... @1:1)  @ C:\Users\Administrator\.m2\repository\org\springframework\cloud\spring-cloud-build-dependencies\2.0.5.RELEASE\spring-cloud-build-dependencies-2.0.5.RELEASE.pom, line 1, column 1
[FATAL] Non-parseable POM C:\Users\Administrator\.m2\repository\org\springframework\cloud\spring-cloud-openfeign-dependencies\2.0.3.RELEASE\spring-cloud-openfeign-dependencies-2.0.3.RELEASE.pom: only whitespace content allowed before start tag and not \
u0 (position: START_DOCUMENT seen \u0... @1:1)  @ C:\Users\Administrator\.m2\repository\org\springframework\cloud\spring-cloud-openfeign-dependencies\2.0.3.RELEASE\spring-cloud-openfeign-dependencies-2.0.3.RELEASE.pom, line 1, column 1
[FATAL] Non-parseable POM C:\Users\Administrator\.m2\repository\org\springframework\cloud\spring-cloud-bus-dependencies\2.0.1.RELEASE\spring-cloud-bus-dependencies-2.0.1.RELEASE.pom: only whitespace content allowed before start tag and not \u0 (position
: START_DOCUMENT seen \u0... @1:1)  @ C:\Users\Administrator\.m2\repository\org\springframework\cloud\spring-cloud-bus-dependencies\2.0.1.RELEASE\spring-cloud-bus-dependencies-2.0.1.RELEASE.pom, line 1, column 1
[FATAL] Non-parseable POM C:\Users\Administrator\.m2\repository\org\springframework\cloud\spring-cloud-gateway-dependencies\2.0.3.RELEASE\spring-cloud-gateway-dependencies-2.0.3.RELEASE.pom: only whitespace content allowed before start tag and not \u0 (
position: START_DOCUMENT seen \u0... @1:1)  @ C:\Users\Administrator\.m2\repository\org\springframework\cloud\spring-cloud-gateway-dependencies\2.0.3.RELEASE\spring-cloud-gateway-dependencies-2.0.3.RELEASE.pom, line 1, column 1
[FATAL] Non-parseable POM C:\Users\Administrator\.m2\repository\org\springframework\cloud\spring-cloud-build-dependencies\2.0.5.RELEASE\spring-cloud-build-dependencies-2.0.5.RELEASE.pom: only whitespace content allowed before start tag and not \u0 (posi
tion: START_DOCUMENT seen \u0... @1:1)  @ C:\Users\Administrator\.m2\repository\org\springframework\cloud\spring-cloud-build-dependencies\2.0.5.RELEASE\spring-cloud-build-dependencies-2.0.5.RELEASE.pom, line 1, column 1

果真: The POM for org.springframework.cloud:spring-cloud-starter-alibaba-nacos-discovery:jar:0.2.2.RELEASE is invalid

肯定無疑, pom 問題, 觀察發現 spring-cloud-starter-alibaba-nacos-config-0.2.2.RELEASE ,以及 spring-cloud-starter-alibaba-nacos-discovery-0.2.2.RELEASE 也有一樣的問題。刪除從新下載,但仍是有問題。

 

另外觀察到 spring-cloud-build-dependencies-2.0.5.RELEASE.pom 也有問題:

難道maven 私服出現了問題? 登陸上去一看, 發現maven 私服的 spring-cloud-build-dependencies-2.0.5.RELEASE.pom 等 都是正常的!

 

難道要一個個的檢查repository目錄中的 pom 是否有問題? 這太多了,乾脆所有刪除出現下載。不得已, 把 程序所有關閉,idea退出,整個repository目錄(C:\Users\Administrator\.m2\repository )刪除,重啓idea ,刷新maven, 問題解決!

 

忽而想到了, 我上午的時候, 電腦電源線鬆動了, 電腦異常關機了一次, 而後, 電腦還自動升級了好久。 可能正是這個緣由致使了 某些的 pom 文件損壞了吧!!!

真是奇了怪了, 這個問題是怎麼引發的呢? 是什麼緣由呢? 網上並無找到這種問題現象,bing 上面搜索 maven pom damaged 或  maven pom corrupted 都無果。

彷佛你們都沒有遇到, 就我一我的遇到?  真是活久見!!!

 

參考:

https://blog.csdn.net/cuiy6642/article/details/49789763

http://www.cnblogs.com/enjoyjava/p/9743460.html

https://grokbase.com/t/ant/user/09771k6h5v/maven2-pom-is-corrupt

相關文章
相關標籤/搜索