Java – error: unable to determine the type parameter of T during Maven installation
•
Java
I have this feature that throws strange errors when I try to do an "MVN installation"
public <T> T get(final AN_ENUM key) { return some_map.get(key); }
This is the wrong line I got
final int value = get(AN_ENUM.A_FIELD);
This is an error in Maven:
XXX.java:[25,41] type parameters of <T>T cannot be determined; no unique maximal instance exists for type variable T with upper bounds int,java.lang.Object
I already know how to "fix" I just need to change int to integer in the last code example and the error disappears It tells me that maven, for some reason, when I use type parameters, I can't take integers as int
My question is... Why?
During the eclipse, using the same JDK, I have been able to run my application without any kind of trouble or warning
>JDK 1.6 eclipse indigo service version 2 > Maven 3.0 four
Solution
In your POM XML, set the target version to at least 1.5:
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>2.0.2</version> <configuration> <source>1.5</source> <target>1.5</target> </configuration> </plugin>
In this way, Maven will use JDK 1.5 (you can set it to 1.6 if necessary)
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码