maven compilation failure

前端 未结 18 2182
不知归路
不知归路 2020-12-07 17:57

I have a weird problem - Some class file couldn\'t be read during maven build.

  1. I have a project A and project B.
  2. Project
相关标签:
18条回答
  • 2020-12-07 18:41

    It also matters the order of the dependencies. I've had the same issue. And basically I had to put first the scope test and then scope compile dependencies in the pom.xml. If I put first the scope compile and then the scope test it will fail.

    0 讨论(0)
  • 2020-12-07 18:41

    I had the same issue (even though the project was compiling/working fine in Eclipse), it was not when using the command line build. The reason was that I wasn't using the correct folder structure for mvn: "src/main/java/com" etc. It is looking at these folders by default (I was using "/scr/main/com" etc. which caused issues).

    0 讨论(0)
  • 2020-12-07 18:44

    Try to use:

    mvn clean package install
    

    This command should install your artifacts in you local maven repo.

    PS: I see that this is an old question, but it may be helpful for somebody in the future.

    0 讨论(0)
  • 2020-12-07 18:44

    go to the maven repository and open the jar [tip: you can use winzip] of the source module to verify the specific class present.

    In my case it is not. Then I found below.

    if you are using the plugin org.apache.felix/maven-bundle-plugin

    Make sure source module has export-package defined

    example: com.xxx.camel.dao

    0 讨论(0)
  • 2020-12-07 18:45

    The error is pretty clear: "cannot find symbol". Some dependencies can't be resolved (you even have the line and column in the trace of the reference that can't be resolved):

    V:/dhs_tss_build_view/dhs_tssproject/tss/tsscommon-server/src/main/java/us/mn/state/dhs/tss/common/oblix/da/wsdl/OblixLoginAc
    cess.java:[51,60] cannot find symbol
    symbol  : class BusinessException
    location: class us.mn.state.dhs.tss.common.oblix.da.wsdl.OblixLoginAccess
    
    V:/dhs_tss_build_view/dhs_tssproject/tss/tsscommon-server/src/main/java/us/mn/state/dhs/tss/common/app/da/ldap/BaseLdapImpl.j
    ava:[187,14] cannot find symbol
    symbol  : class Phone
    location: class us.mn.state.dhs.tss.common.app.da.ldap.BaseLdapImpl
    
    V:/dhs_tss_build_view/dhs_tssproject/tss/tsscommon-server/src/main/java/us/mn/state/dhs/tss/common/app/da/ldap/BaseLdapImpl.j
    ava:[204,14] cannot find symbol
    symbol  : class Phone
    location: class us.mn.state.dhs.tss.common.app.da.ldap.BaseLdapImpl
    

    Below a couple of things to verify:

    • Check or recheck that these classes are in the jar A (same version as in the pom)
    • Check or recheck the import statement in B sources (should match the package of classes in A)
    • Check or recheck B's pom.xml and especially the declaration of the dependency on A (it's version)
    • Check that the dependency on A is not excluded transitively somewhere in B's pom
    • Is A a SNAPSHOT dependency? If no, delete A from your local repository and rebuild

    Maven is working fine, you have a mistake somewhere.

    0 讨论(0)
  • I had the same problem...

    How to fix - add the following properties in to the pom.xml

    <properties>
        <!--  compiler settings -->
        <maven.compiler.source>1.6</maven.compiler.source>
        <maven.compiler.target>1.6</maven.compiler.target>
    </properties>        
    
    0 讨论(0)
提交回复
热议问题