我一直在将我的开发环境更新到Eclipse Neon并引入了m2e来管理项目依赖关系。在一个项目中,原始(非常旧)版本的JFreeChart
在maven上不可用,所以我已经放入最新版本的JFreeChart
和JCommon
。无法解析类型org.jfree.data.general.Series
我现在有一个编译错误,说明如下:
The type org.jfree.data.general.Series cannot be resolved.
It is indirectly referenced from required .class files.
我已经找到了一些关于这个问题和答案,但他们似乎都与缺乏JCommon
。我在我的依赖关系中有JCommon
,并且我已经检查过提到的具体类实际上是带有7-zip的jfreechart.jar
文件。 下面是带有错误的代码片段,它出现在last else语句results.add(…)
上。
public XYDataset getMetricHistogramData(Timestamp t1, Timestamp t2){
int index1=-1;
Timestamp startTime,endTime;
TimePeriodValues results = new TimePeriodValues(this.type.name());
final TimePeriodValuesCollection results1 = new TimePeriodValuesCollection();
if (t1.before(earliest)||t1.after(latest)||(readings.size()<=1)) return null; // won't find a value for the timestamp t1
if (t2.before(earliest)||t2.after(latest)) return null; // won't find a value for the timestamp t2
for(int i = 0;i<readings.size();i++){
if (readings.get(i).timestamp().equals(t1)){
index1=i;
break;
}
if (readings.get(i).timestamp().after(t1)){
index1=i-1;
break;
}
}
// index1 now contains the index of the starting timestamp
for (int i=index1; i<(readings.size()-1); i++){
startTime = readings.get(i).timestamp();
if(startTime.after(t2)) break;
//endTime = new Timestamp(Math.abs(readings.get(i+1).timestamp().getTime()-Timestamped.SECOND_IN_MS));
endTime = readings.get(i+1).timestamp();
if (endTime.before(startTime))
SmartPower.getMain().getFrame().displayLog("Bad Timestamps "+startTime + " - " + endTime+"\n\r");
else results.add(new SimpleTimePeriod(startTime, endTime), readings.get(i).value());
}
results1.addSeries(results);
return results1;
}
这是我的pom.xml文件
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>SmartPower</groupId>
<artifactId>SmartPower</artifactId>
<version>0.0.1-SNAPSHOT</version>
<build>
<sourceDirectory>src</sourceDirectory>
<resources>
<resource>
<directory>src</directory>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</resource>
</resources>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<!-- https://mvnrepository.com/artifact/org.eclipse.persistence/javax.persistence -->
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>javax.persistence</artifactId>
<version>2.1.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.jfree/jfreechart -->
<dependency>
<groupId>org.jfree</groupId>
<artifactId>jfreechart</artifactId>
<version>1.0.19</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.jfree/jcommon -->
<dependency>
<groupId>org.jfree</groupId>
<artifactId>jcommon</artifactId>
<version>1.0.23</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.jgoodies/forms -->
<dependency>
<groupId>com.jgoodies</groupId>
<artifactId>forms</artifactId>
<version>1.2.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.derby/derby -->
<dependency>
<groupId>org.apache.derby</groupId>
<artifactId>derby</artifactId>
<version>10.12.1.1</version>
</dependency>
</dependencies>
</project>
霓虹灯是一个干净的前窗上10
任何指针将不胜感激安装一个星期左右。
如果这是没有帮助的,请编辑您的问题,包括展现你描述的问题的[mcve]。 – trashgod
这指出了Eclipse环境的问题,而不是jar文件。我想我已经在原始问题中提供了所有的细节。我会尝试你在我的环境中编码片段。 – gjwo
我在我的结构org.ladbury.testPkg中添加了一个测试包,然后使用上面的代码在包中创建了一个新的测试类。我在包装语句“The org.jfree.data.DomainInfo无法解析,它从所需的.class文件间接引用”+其他各种错误中得到一个错误。该类也存在于jfreechar.jar文件中。我注意到你的jar文件在版本后包含“-fx”,我的不是这个重要的东西吗? – gjwo