Invalid maven compilation error (works in eclipse)

I get a compilation error when compiling using maven, but it works in eclipse. Both use 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 mistake:

[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 this is a rather recursive problem, I found several posts asking the same thing, but nobody seems to have a standard fix. Some say it works with a different version of the JDK. I tested with 1.6.0_30, 1.6.0_31, 1.6.0_32 and 1.6.0_35, and all failed.

Any idea?

thank

+5
source share
1 answer

I suspect that Eclipse is not using the JDK, which is what you think. Try erasing styles.

Collection<? extends MessageGroup> collection = 
        (Collection<? extends MessageGroup>)
                (Collection) this.groupMap.values();
+14
source

All Articles