Я пытаюсь заставить работать VertX Mertrics при запуске через подключаемый модуль exec:java
Maven. .
Все работает, как и ожидалось, когда я упаковываю приложение в фатжар и запускаю его с помощью java -jar fat.jar -conf config.json -Dvertx.metrics.options.enabled=true
Когда я запускаю его с помощью mvn clean package exec:java -DskipTests
, я вижу:
2016-03-22 18:39:58.833 WARN i.v.c.i.VertxImpl:348 - Metrics has been set to enabled but no VertxMetricsFactory found on classpath
Я пробовал несколько подходов:
- добавление
io.vertx:vertx-dropwizard-metrics:3.2.1
в качестве зависимости компиляции - создать внутреннюю реализацию метрик и зарегистрировать ее с помощью файла
src/main/resources/META-INF/services/io.vertx.core.spi.VertxMetricsFactory
(перепроверил, что он действительно скопирован вtarget/classes/META-INF/services/io.vertx.core.spi.VertxMetricsFactory
) - также добавление
${basedir}/src/main/resources
в качестве дополнительного элемента пути к классам (в дополнение к предыдущему пункту)
Я дважды проверил в отладчике, что ServiceLoader
на самом деле возвращает пустой итератор.
Это моя конфигурация exec-плагина:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<configuration>
<additionalClasspathElements>
<element>${basedir}/src/main/resources</element>
</additionalClasspathElements>
<mainClass>io.vertx.core.Launcher</mainClass>
<commandlineArgs>run ${vertx.mainVerticle} -conf ${vertx.config}</commandlineArgs>
<systemProperties>
<systemProperty>
<key>vertx.logger-delegate-factory-class-name</key>
<value>io.vertx.core.logging.SLF4JLogDelegateFactory</value>
</systemProperty>
<systemProperty>
<key>vertx.metrics.options.enabled</key>
<value>true</value>
</systemProperty>
</systemProperties>
</configuration>
</plugin>
Вот конфигурация exec:exec
, которая работает, но я хочу понять, возможно ли и почему (не)возможно сделать это с exec:java
<profile>
<id>exec</id>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>exec</goal>
</goals>
<phase>process-classes</phase>
<configuration>
<executable>java</executable>
<arguments>
<argument>-Dvertx.metrics.options.enabled=true</argument>
<argument>-Dvertx.logger-delegate-factory-class-name=${vertx.logger-delegate-factory-class-name}</argument>
<argument>-classpath</argument>
<classpath />
<argument>io.vertx.core.Launcher</argument>
<argument>run</argument>
<argument>${vertx.mainVerticle}</argument>
<argument>-conf</argument>
<argument>${vertx.config}</argument>
</arguments>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>