我尝试在Windows 7上使用scriptom 1.6连接到excel应用程序。但是我一直收到错误:
Caught: java.lang.IncompatibleClassChangeError: Class org.codehaus.groovy.scriptom.ActiveXObject does not implement the requested interface groovy.lang.GroovyObject
at GoBeby.main(GoBeby.groovy:14)
这是我的代码:
import org.codehaus.groovy.scriptom.ActiveXObject;
class GoExcel {
public static void main(String[] args) {
ActiveXObject excel = new ActiveXObject("Excel.Application")
excel.Visible = true;
}
}
和maven文件:
<?xml version="1.0" encoding="UTF-8"?>
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.examples</groupId>
<name>${project.artifactId}</name>
<artifactId>go_excel</artifactId>
<packaging>jar</packaging>
<version>0.1</version>
<properties>
<gmaven.version>1.2</gmaven.version>
<groovy.version>1.7.10</groovy.version>
<slf4j.version>1.5.10</slf4j.version>
</properties>
<dependencies>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>${slf4j.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
<version>${slf4j.version}</version>
</dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy</artifactId>
<version>${groovy.version}</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.13</version>
</dependency>
<!-- scriptom -->
<dependency>
<groupId>org.codehaus.groovy.modules.scriptom</groupId>
<artifactId>scriptom</artifactId>
<version>1.6.0</version>
</dependency>
<dependency>
<groupId>net.sf.jacob-project</groupId>
<artifactId>jacob</artifactId>
<version>1.14.3</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>net.sf.jacob-project</groupId>
<artifactId>jacob</artifactId>
<version>1.14.3</version>
<type>dll</type>
<classifier>x64</classifier>
</dependency>
<dependency>
<groupId>net.sf.jacob-project</groupId>
<artifactId>jacob</artifactId>
<version>1.14.3</version>
<type>dll</type>
<classifier>x86</classifier>
</dependency>
<!-- / scriptom -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.7</version>
<scope>test</scope>
</dependency>
</dependencies>
<repositories>
<repository>
<id>central</id>
<name>Maven Repository Switchboard</name>
<layout>default</layout>
<url>http://repo1.maven.org/maven2</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-eclipse-plugin</artifactId>
<version>2.8</version>
<configuration>
<downloadSources>true</downloadSources>
<downloadJavadocs>true</downloadJavadocs>
<projectnatures>
<projectnature>org.eclipse.jdt.groovy.core.groovyNature
</projectnature>
<projectnature>org.eclipse.jdt.core.javanature</projectnature>
</projectnatures>
</configuration>
</plugin>
</plugins>
</build>
</project>
我刚刚用完了想法。我检查使用jacob 64位和32位dll,将groovy框架更改为1.5。有谁知道如何让它发挥作用?