简体   繁体   English

如何编译混合(Java 和 Groovy)项目?

[英]How to compile mixed (Java and Groovy) project?

I have a project (Java Swing application), in which I want to mix Java and Groovy.我有一个项目(Java Swing 应用程序),我想在其中混合使用 Java 和 Groovy。

I can compile and run the project without problems inside IntelliJ Idea.我可以在 IntelliJ Idea 中毫无问题地编译和运行该项目。

But I can't compile it with Maven:但我不能用 Maven 编译它:

  1. In src/main/groovy I define a Groovy class GroovyClass .src/main/groovy我定义了一个 Groovy 类GroovyClass
  2. In src/main/java there is a Java class, which uses GroovyClass .src/main/java有一个 Java 类,它使用GroovyClass
  3. When compiling the project with Maven, I get the message [ERROR] ...\\JavaClass.java:[13,47] error: cannot find symbol .使用 Maven 编译项目时,我收到消息[ERROR] ...\\JavaClass.java:[13,47] error: cannot find symbol

How can I change the pom.xml file in order to be able to compile and package the application using Maven?如何更改pom.xml文件以便能够使用 Maven 编译和打包应用程序?

Add the groovy-eclipse compiler maven plugin to your pom.xml将 groovy-eclipse 编译器 maven 插件添加到您的 pom.xml

Instructions are on the plugins page at https://github.com/groovy/groovy-eclipse/wiki/Groovy-Eclipse-Maven-plugin说明位于https://github.com/groovy/groovy-eclipse/wiki/Groovy-Eclipse-Maven-plugin的插件页面上

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM