• 活久见: maven pom 竟然都会崩溃!


    问题是: 我的应用的pom 并没有任何报错,但是代码报错,而且编译不通过。

    如下,我本地项目,从 spring-cloud-alibaba-dependencies 0.2.1.RELEASE 升级到 0.2.2.RELEASE: 

                <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" ,比如这个:

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

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

    spring cloud 相关的类/接口 似乎都不能用了, 但是之前都是好好的啊! 查看maven 的dependencies 图发现, 某些 jar 似乎缺少没有被依赖尽量。 不是某几个, 而是很多的。。。

    似乎某些 dependency 被切断了。。 于是手动添加了几个 dependency 并写上了版本号,要是不写版本号, 那么问题依旧。 难道需要一个个的处理问题?

    之前都不需要手动加入的dependency, 现在一个个手动添加, 也太麻烦了吧!

    观察发现dubbo-registry-nacos-0.0.2.pom 似乎不对, 里面怎么全是NUL 这种黑色字符,经验告诉我,这个是文件格式不对或者编码格式问题, 也可能是文件没有正确结尾,或者是被修改了/截断了.. 怎么办? 这个版本的dubbo-registry-nacos-0.0.2 就是这样的? 查看了同事的这个dubbo-registry-nacos-0.0.2.pom 文件,发现没有这个问题! 删除重新下载吧!(同一个目录下的其他文件 包括jar 也一并全部删除) 就好了 ! 重新下载后pom 是正常了,但是问题依旧。

    经验告诉我,maven 出了问题了, clean 一下吧:

    E:deverdp2erdp_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:deverdp2erdp_discusserdp_discuss_controller	arget
    [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:deverdp2erdp_discusserdp_discuss_controller	argetclasses
    [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:deverdp2erdp_discusserdp_discuss_controller	arget	est-classes
    [INFO] /E:/dev/erdp2/erdp_discuss/erdp_discuss_controller/src/test/java/com/lkk/ppm/discuss/SysConsumerApplication.java: E:deverdp2erdp_discusserdp_discuss_controllersrc	estjavacomlkkppmdiscussSysConsumerApplication.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:deverdp2erdp_discusserdp_discuss_controller	argeterdp_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:deverdp2erdp_discusserdp_discuss_service	arget
    [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:deverdp2erdp_discusserdp_discuss_servicesrcmain
    esources
    [INFO] skip non existing resourceDirectory E:deverdp2erdp_discusserdp_discuss_servicesrcmain
    esources
    [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:deverdp2erdp_discusserdp_discuss_service	argetclasses
    [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:deverdp2erdp_discusserdp_discuss_service	arget	est-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:deverdp2erdp_discusserdp_discuss_service	argeterdp_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:deverdp2erdp_discusserdp_discuss_app	arget
    [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:deverdp2erdp_discusserdp_discuss_app	argetclasses
    [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:UsersAdministrator.m2
    epositoryorgspringframeworkcloudspring-cloud-build-dependencies2.0.5.RELEASEspring-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:UsersAdministrator.m2
    epositoryorgspringframeworkcloudspring-cloud-build-dependencies2.0.5.RELEASEspring-cloud-build-dependencies-2.0.5.RELEASE.pom, line 1, column 1
    [FATAL] Non-parseable POM C:UsersAdministrator.m2
    epositoryorgspringframeworkcloudspring-cloud-openfeign-dependencies2.0.3.RELEASEspring-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:UsersAdministrator.m2
    epositoryorgspringframeworkcloudspring-cloud-openfeign-dependencies2.0.3.RELEASEspring-cloud-openfeign-dependencies-2.0.3.RELEASE.pom, line 1, column 1
    [FATAL] Non-parseable POM C:UsersAdministrator.m2
    epositoryorgspringframeworkcloudspring-cloud-bus-dependencies2.0.1.RELEASEspring-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:UsersAdministrator.m2
    epositoryorgspringframeworkcloudspring-cloud-bus-dependencies2.0.1.RELEASEspring-cloud-bus-dependencies-2.0.1.RELEASE.pom, line 1, column 1
    [FATAL] Non-parseable POM C:UsersAdministrator.m2
    epositoryorgspringframeworkcloudspring-cloud-gateway-dependencies2.0.3.RELEASEspring-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:UsersAdministrator.m2
    epositoryorgspringframeworkcloudspring-cloud-gateway-dependencies2.0.3.RELEASEspring-cloud-gateway-dependencies-2.0.3.RELEASE.pom, line 1, column 1
    [FATAL] Non-parseable POM C:UsersAdministrator.m2
    epositoryorgspringframeworkcloudspring-cloud-build-dependencies2.0.5.RELEASEspring-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:UsersAdministrator.m2
    epositoryorgspringframeworkcloudspring-cloud-build-dependencies2.0.5.RELEASEspring-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:UsersAdministrator.m2
    epositoryorgjboss
    etty
    etty3.2.5.Final
    etty-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:UsersAdministrator.m2
    epositoryorgspringframeworkcloudspring-cloud-build-dependencies2.0.5.RELEASEspring-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:UsersAdministrator.m2
    epositoryorgspringframeworkcloudspring-cloud-build-dependencies2.0.5.RELEASEspring-cloud-build-dependencies-2.0.5.RELEASE.pom, line 1, column 1
    [FATAL] Non-parseable POM C:UsersAdministrator.m2
    epositoryorgspringframeworkcloudspring-cloud-openfeign-dependencies2.0.3.RELEASEspring-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:UsersAdministrator.m2
    epositoryorgspringframeworkcloudspring-cloud-openfeign-dependencies2.0.3.RELEASEspring-cloud-openfeign-dependencies-2.0.3.RELEASE.pom, line 1, column 1
    [FATAL] Non-parseable POM C:UsersAdministrator.m2
    epositoryorgspringframeworkcloudspring-cloud-bus-dependencies2.0.1.RELEASEspring-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:UsersAdministrator.m2
    epositoryorgspringframeworkcloudspring-cloud-bus-dependencies2.0.1.RELEASEspring-cloud-bus-dependencies-2.0.1.RELEASE.pom, line 1, column 1
    [FATAL] Non-parseable POM C:UsersAdministrator.m2
    epositoryorgspringframeworkcloudspring-cloud-gateway-dependencies2.0.3.RELEASEspring-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:UsersAdministrator.m2
    epositoryorgspringframeworkcloudspring-cloud-gateway-dependencies2.0.3.RELEASEspring-cloud-gateway-dependencies-2.0.3.RELEASE.pom, line 1, column 1
    [FATAL] Non-parseable POM C:UsersAdministrator.m2
    epositoryorgspringframeworkcloudspring-cloud-build-dependencies2.0.5.RELEASEspring-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:UsersAdministrator.m2
    epositoryorgspringframeworkcloudspring-cloud-build-dependencies2.0.5.RELEASEspring-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:UsersAdministrator.m2 epository )删除,重启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

  • 相关阅读:
    indy tcpclient tcpServer
    Delphi生成即调用带窗体的Dll
    本地同步到网络时间
    tfield的字段名和显示名
    Delphi流的操作_文件合并
    Delphi7 流操作_压缩
    delphi内嵌汇编
    给rar文件加个自定义头
    fastreport小入门
    delphi 单例模式
  • 原文地址:https://www.cnblogs.com/FlyAway2013/p/10818867.html
Copyright © 2020-2023  润新知