D.3. 在任何 Maven 项目中运行目标
您还可以在任何 Maven 项目中运行验证目标,而无需将插件添加到 pom.xml
文件中。您需要使用其完全限定名称来指定插件。
流程
要在 Apache Camel 的
camel-example-cdi
插件上运行目标,请运行以下命令:$cd camel-example-cdi $mvn io.fabric8.forge:fabric8-camel-maven-plugin:2.3.80:validate
这将显示以下输出:
[INFO] ------------------------------------------------------------------------ [INFO] Building Camel :: Example :: CDI 2.16.2 [INFO] ------------------------------------------------------------------------ [INFO] [INFO] --- fabric8-camel-maven-plugin:2.3.80:validate (default-cli) @ camel-example-cdi --- [INFO] Endpoint validation success: (4 = passed, 0 = invalid, 0 = incapable, 0 = unknown components) [INFO] Simple validation success: (0 = passed, 0 = invalid) [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------
成功传递验证后,您可以验证四个端点。以下示例演示了如何验证和在需要时正确验证 camel 端点。
示例
让我们假定您在源代码中的 Camel 端点 URI 中做了拼写错误,例如:
正确的 Camel enpoint URI 如下所示:
@Uri("timer:foo?period=5000")
您可以进行更改以在
句点
选项中包含拼写错误,例如:@Uri("timer:foo?perid=5000")
再次运行验证目标。
[INFO] ------------------------------------------------------------------------ [INFO] Building Camel :: Example :: CDI 2.16.2 [INFO] ------------------------------------------------------------------------ [INFO] [INFO] --- fabric8-camel-maven-plugin:2.3.80:validate (default-cli) @ camel-example-cdi --- [WARNING] Endpoint validation error at: org.apache.camel.example.cdi.MyRoutes(MyRoutes.java:32) timer:foo?perid=5000 perid Unknown option. Did you mean: [period] [WARNING] Endpoint validation error: (3 = passed, 1 = invalid, 0 = incapable, 0 = unknown components) [INFO] Simple validation success: (0 = passed, 0 = invalid) [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------
如上方显示 camel 端点 URI 中的错误。