I have a weird problem - Some class file couldn\'t be read during maven build.
A
and project B
.It's easy to get this error in a multi-module project. If, for example, you made changes to modules A, B, and C, but then you try to compile just module B, you are susceptible to this error. Say module B has a dependency on module A. Since only module B was compiled, the class files from module A are now out of date and possibly invalid.
Compiling all the modules (or modules in the proper hierarchical dependency order) resolves this error, if this is the nature of your problem.
I had the same problem and this is how I suggest you fix it:
Run:
mvn dependency:list
and read carefully if there are any warning messages indicating that for some dependencies there will be no transitive dependencies available.
If yes, re-run it with -X flag:
mvn dependency:list -X
to see detailed info what is maven complaining about (there might be a lot of output for -X flag)
In my case there was a problem in dependent maven module pom.xml - with managed dependency. Although there was a version for the managed dependency defined in parent pom, Maven was unable to resolve it and was complaining about missing version in the dependent pom.xml
So I just configured the missing version and the problem disappeared.
My guess is a wrong version of project A jar in your local maven repository. It seems that the dependency is resolved otherwise I think maven does not start compiling but usually these compiling error means that you have a version mix up. try to make a maven clean install
of your project A and see if it changes something for the project B...
Also a little more information on your setting could be useful:
After running following command:-
mvn clean package install
I found the issue:
'dependencies.dependency.scope' for org.springframework.boot:spring-boot-starter-data-rest:pom must be one of [provided, compile, runtime, test, system] but is 'import'. @ line 13, column 11
One of the dependency was marked as 'import'. Changing the 'scope' solved the issue for me.
You could try running the "mvn site" command and see what transitive dependencies you have, and then resolve potential conflicts (by ommitting an implicit dependency somewhere). Just a guess (it's a bit difficult to know what the problem could be without seeing your pom info)...
I had a similar problem, and never find anything on the web after excessive searching.
I reviewed the pom.xml
file and in the dependencies I changed the scope of the <dependency>
it:
<scope>test</scope>
to <scope>compile</scope>
.
Previously I was using it only for tests but I change the project's structure and never knew I hve to change this.
test: This scope indicates that the dependency is not required for normal use of the application, and is only available for the test compilation and execution phases.
compile: This is the default scope, used if none is specified. Compile dependencies are available in all classpaths of a project. Furthermore, those dependencies are propagated to dependent projects.
Here is a reference from Apache Maven Docs: https://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html#Dependency_Scope