这是重写我之前的问题,因为这令人困惑。基本上我有groovy mix java maven项目。我想在java文件中调用我的groovy类我已经编写了这样的代码 import login.Login;
import groovy.lang.GroovyObject;
import groovy.net.xmlrpc.XMLRPCServerProxy;
public class TestConnectionServlet {
public String process(String parameter) throws {
GroovyObject groovyOject =new Login();//my groovy class
String sessionId ="";
try {
XMLRPCServerProxy serverProxy = (XMLRPCServerProxy) groovyOject.invokeMethod("getServerProxy", "https://myisteproxy");
sessionId = (String) groovyOject.invokeMethod("getSession",new Object[]{"username","password",serverProxy});
} catch(Exception e) {
Logger.error(this.getClass().getName(), "error during login", e);
}
System.out.println("session id.."+sessionId);
return null;
}
}
当我通过main方法运行它时工作正常但是当我使用目标clean install
编译我的maven项目时,它给了我一个groovy类不会退出的错误。我检查了我的构建路径src/main/groovy
已添加。而且我很时髦 - 我的maven dependecy中的所有jar都是我的maven依赖
<dependencies>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-xmlrpc</artifactId>
<version>0.8</version>
</dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
<version>2.4.11</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<proc>none</proc>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.gmavenplus</groupId>
<artifactId>gmavenplus-plugin</artifactId>
<version>1.5</version>
<executions>
<execution>
<goals>
<goal>addSources</goal>
<goal>compile</goal>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
<version>2.4.11</version>
</dependency>
</dependencies>
<configuration>
<sources>
<source>
<directory>${project.basedir}/src</directory>
<includes>
<include>**/*.groovy</include>
</includes>
</source>
</sources>
</configuration>
</plugin>
</plugins>
</build>
请让我知道我错过了什么?