【发布时间】:2016-10-30 10:24:30
【问题描述】:
我有这些课程:
public class EntityDataModel<T extends AbstractEntity>
{
...
}
public abstract class BarChartBean<E extends ChartEntry, T>
{
protected EntityDataModel<? extends T> currentModel;
...
}
我可以在eclipse上编译和运行这段代码没有问题,但是当我调用mvn compile时,会抛出这个错误:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.5.1:compile (default-compile) on project edea2: Compilation failure: Compilation failure:
[ERROR] C:\Develop\...\BarChartBean.java:[53,30] error: type argument ? extends T#1 is not within bounds of type-variable T#2
[ERROR] where T#1,T#2 are type-variables:
[ERROR] T#1 extends Object declared in class BarChartBean
[ERROR] T#2 extends AbstractEntity declared in class EntityDataModel
这个错误不言自明,理论上来说javac是对的,eclipse编译器是错的。
为什么会有这样的差异?
这里是环境的详细信息:
-
日食
-
Maven
- Apache Maven 3.3.3 (7994120775791599e205a5524ec3e0dfe41d4a06; 2015-04-22T13:57:37+02:00)
- Maven 主页:C:\Develop\tools\apache-maven-3.3.3
- Java 版本:1.8.0_71,供应商:甲骨文公司
- Java 主页:C:\Program Files\Java\jdk1.8.0_71\jre
- 默认语言环境:it_IT,平台编码:Cp1252
- 操作系统名称:“windows 10”,版本:“10.0”,arch:“amd64”,家族:“dos”
-
maven-compiler-plugin:
<plugin> <artifactId>maven-compiler-plugin</artifactId> <version>2.5.1</version> <configuration> <source>1.8</source> <target>1.8</target> <encoding>UTF-8</encoding> <showDeprecation>true</showDeprecation> <showWarnings>true</showWarnings> </configuration> </plugin>
问题:我如何对齐 eclipse 编译器行为到 javac(但我不想在 eclipse 中使用 javac)?
【问题讨论】:
标签: java eclipse maven maven-3 maven-compiler-plugin