I'm getting a compilation error when I compile using maven but works in eclipse. Both are using the same JDK:
java -version
java version "1.6.0_35"
Java(TM) SE Runtime Environment (build 1.6.0_35-b10)
Java HotSpot(TM) 64-Bit Server VM (build 20.10-b01, mixed mode)
mvn -version
Apache Maven 3.0.4
Maven home: /usr/share/maven
Java version: 1.6.0_35, vendor: Sun Microsystems Inc.
Java home: /usr/lib/jvm/jdk1.6.0_35/jre
Default locale: es_ES, platform encoding: UTF-8
OS name: "linux", version: "3.2.0-29-generic", arch: "amd64", family: "unix"
This is the error:
[ERROR] /blablabla.../myClass.java: [78,107] inconvertible types
[ERROR] found : java.util.Collection<java.lang.Object>
[ERROR] required: java.util.Collection<? extends org.springframework.integration.store.MessageGroup>
[ERROR] -> [Help 1]
And this is the code (no compilation error in eclipse):
Collection<? extends MessageGroup> collection = (Collection<? extends MessageGroup>) this.groupMap.values();
I know that this is a pretty recursive issue, I've found a few posts asking the same, but seems that nobody has a standar fix. Some people say that works with different JDK version. I have tested with 1.6.0_30, 1.6.0_31, 1.6.0_32 and 1.6.0_35 and all fail.
Any idea?
Thanks
The error message indicates that Maven is unable to find the Java compiler, which comes only with a JDK and not with a JRE.
Additionally,right click on the pom. xml file in the 'project explorer' > click on 'validate'. This should remove the red-error mark on file, if there are no problems in the XML configuration.
I suspect eclipse isn't using the JDK you think it is. Try using type erasure.
Collection<? extends MessageGroup> collection =
(Collection<? extends MessageGroup>)
(Collection) this.groupMap.values();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With