我有一个用于登录Json格式的自定义Wildfly模块,我的Swarm应用程序在standalone.xml中引用:
<subsystem xmlns="urn:jboss:domain:logging:3.0">
<console-handler name="CONSOLE">
<level name="INFO" />
<formatter>
<named-formatter name="json-formatter" />
</formatter>
</console-handler>
...
<formatter name="json-formatter">
<custom-formatter module="my.package.jsonLogFormatter" class="my.package.jsonLogFormatter.JsonFormatter"/>
</formatter>
</subsystem>
该模块保存在Maven存储库中,在Maven构建期间将其从中复制到target / classes文件夹。
Maven wildfly-swarm-plugin然后将模块添加到uberjar:
<plugin>
<groupId>org.wildfly.swarm</groupId>
<artifactId>wildfly-swarm-plugin</artifactId>
<version>2017.7.0</version>
<executions>
<execution>
<goals>
<goal>package</goal>
</goals>
</execution>
</executions>
<configuration>
<additionalModules>
<additionalModule>jsonLogFormatter-1.2</additionalModule>
</additionalModules>
</configuration>
</plugin>
从uberjar执行时,这可以正常工作。
但是,当直接从IDE运行自定义main()类时,似乎无法告诉Swarm使用此模块:
public static void main(String... args) throws Exception {
new org.wildfly.swarm.Swarm()
//.customModule("path/to/module") // <- doesn't exist
.start()
.deploy();
}
Swarm在启动时显示此错误:
Failed to load module "my.package.jsonLogFormatter" for formatter "json-formatter"