我有一个带有Java和Groovy文件的项目,希望将这两个文件编译成.class。
我的Groovy类使用Java类。Java类中的一个包含注释
@ConfigPartDescriptor(
name = "Mail Service ${jndiName}"
)
@XmlRootElement(name = "mbean")
@XmlAccessorType(XmlAccessType.NONE)
public final class MailServiceBean extends MBeanJaxbBase<MailServiceBean> implements IConfigFragment, Origin.Wise {这对于Java来说是可以的,但是Groovy,尽管它没有编译文件,却抱怨道:
Failed to execute goal org.codehaus.gmaven:gmaven-plugin:1.5:compile (compile-groovy-classes) on project AsMigrator: startup failed:
file:/home/ondra/work/AS/Migration/git-repo/src/main/java/org/jboss/loom/migrators/_groovy/TestJaxbBean.groovy: 20: Expected 'Mail Service $jndiName' to be an inline constant of type java.lang.String in @org.jboss.loom.spi.ann.ConfigPartDescriptor
@ line 20, column 12.
name = "Mail Service ${jndiName}"使用Maven GMaven插件。(Eclipse编译器在同一件事上失败。)
我的猜测是Groovy编译器处理注释,并看到${...},它创建了一个GroovyString而不是String。然后打字机就失败了。
如何解决这个问题?,我可以使用不同的语法,例如%{.},但我不喜欢。
发布于 2013-06-14 08:09:37
您试过单引号了吗,这样Groovy就不会模板它了吗?
@ConfigPartDescriptor( name = 'Mail Service ${jndiName}' )https://stackoverflow.com/questions/17103561
复制相似问题