您希望为 Reflections.collect() 提供什么驱动程序以从 Groovy 脚本工作



我有以下草稿代码片段

import com.google.appengine.api.datastore.Entity
import org.reflections.Reflections
Reflections r = Reflections.collect()
Set<Class<?>> entities = r.getTypesAnnotatedWith(Entity.class)
print entities

这将引发以下异常:

org.xml.sax.SAXException: Can't create default XMLReader; is system property org.xml.sax.driver set?
    at org.xml.sax.helpers.XMLReaderFactory.createXMLReader(Unknown Source)
    at org.dom4j.io.SAXHelper.createXMLReader(SAXHelper.java:83)

谷歌搜索org.xml.sax.SAXException: Can't create default XMLReader; is system property org.xml.sax.driver set?会带来问题,主要是关于仅链接答案的Android或基于代码的答案,这些答案实际上并没有解决提供正确系统属性值的问题。

相同的代码与来自同一 IDE 项目的Java代码一起工作。

那么我必须提供什么才能让它作为 Groovy 脚本工作呢?

我的 Maven 项目的src/test/groovy中有这个脚本,所以我添加了。

<dependency>
    <groupId>org.apache.servicemix.bundles</groupId>
    <artifactId>org.apache.servicemix.bundles.crimson</artifactId>
    <version>1.1.3_2</version>
    <scope>test</scope>
</dependency>

到我的pom.xml

我在脚本Run/Debug ConfigurationVM Options:中添加了-Dorg.xml.sax.driver=org.apache.crimson.parser.XMLReaderImpl

这使它可以工作,但我仍然想知道我可以使用什么而无需添加依赖项来运行test范围内的内容,因为main范围内的内容可以在没有此依赖项的情况下工作。

最新更新