我在注释处理器内部初始化了速度引擎,该处理器扩展了AbstractProcessor,如下所示:
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv)
{
String fqClassName = null;
String className = null;
String packageName = null;
Map<String, VariableElement> fields = new HashMap<String, VariableElement>();
Map<String, ExecutableElement> methods = new HashMap<String, ExecutableElement>();
...
if (fqClassName != null)
{
Properties props = new Properties();
URL url = this.getClass().getClassLoader().getResource("velocity.properties");
VelocityContext velocityContext = null;
Template template = null;
JavaFileObject javaFileObject;
Writer writer;
try
{
processingEnv.getMessager().printMessage(Kind.NOTE, "Before");
props.load(url.openStream());
processingEnv.getMessager().printMessage(Kind.NOTE, "Props: " + props);
VelocityEngine velocityEngine = new VelocityEngine();
velocityEngine.setProperty("resource.loader", "classpath");
velocityEngine.init();
...
} catch (Exception e1)
{
processingEnv.getMessager().printMessage(Kind.ERROR,
"Exception: " + e1.getMessage() + " : " + e1.getStackTrace());
}
}
return false;
}
调用init()
方法时会发生异常。
我将带有Velocity jar文件的处理器导出为jar文件,并配置eclipse以将其用作注释处理器。
答案 0 :(得分:1)
您正在将自定义属性加载到element
变量中,但不会将其传递给Velocity。
因此,您应该简单地执行以下操作:
locals {
outbound_ip_addresses_list = "${split(",", azurerm_app_service.testap.outbound_ip_addresses)}"
}
output "first_ip" {
value = "${local.outbound_ip_addresses_list[0]}"
}