java - Bootique,正在运行的主要示例,服务器选项未显示
问题描述
我正在关注bootique.io的入门指南,我似乎遇到了一些可能与我的 maven 配置相关的内容,或者可能与 bootique.io 中最近未包含在入门指南中的更改有关的内容。
我创建了一个简单的 github 项目来遵循这里的指南(git clone 和 mvn 包,java -jar target/bootique-tryout-1-jar-with-dependencies.jar 运行)。
入门指南指出,在编译并运行 jar 之后,您应该会看到如下所示的选项列表:
NAME
com.foo.Application
OPTIONS
-c yaml_location, --config=yaml_location
Specifies YAML config location, which can be a file path or a URL.
-h, --help
Prints this message.
-H, --help-config
Prints information about application modules and their configuration
options.
-s, --server
Starts Jetty server.
但是,当我运行上述后续版本时,我会看到:
NAME
bootique-tryout-1-jar-with-dependencies.jar
OPTIONS
-c yaml_location, --config=yaml_location
Specifies YAML config location, which can be a file path or a URL.
-h, --help
Prints this message.
-H, --help-config
Prints information about application modules and their configuration
options.
注意缺少的-s, --server
选项。我错过了什么(明显的?)东西?
解决方案
啊,在论坛里翻了一下,我发现这是由于在处理由 maven-assembly-plugin 和 maven-shade-plugin 生成的组合 jar 时的一些 bootique 特定设置。
我删除了基于 maven-assembly-plugin 的 jar-with-dependencies 并将其替换为 maven-shade-plugin,配置如下:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.1.1</version>
<configuration>
<createDependencyReducedPom>true</createDependencyReducedPom>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer" />
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>${main.class}</mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
当我现在mvn clean package
尝试运行应用程序时,我看到了-s, --server
预期的选项:
NAME
bootique-tryout-1.jar
OPTIONS
-c yaml_location, --config=yaml_location
Specifies YAML config location, which can be a file path or a URL.
-h, --help
Prints this message.
-H, --help-config
Prints information about application modules and their configuration
options.
-s, --server
Starts Jetty server.
我已经使用上述修复更新了我的示例项目。
推荐阅读
- powershell - AD中的用户创建
- swift - 可选属性导致 Swift 协议崩溃
- python - 正则表达式中的 Python 可选组
- python - Python selenium - 我如何能够点击屏幕上具有特定值的所有按钮
- sql - JOIN 条件下的 SQL 查询
- python - Python numpy:用特定范围内的新值替换值的for循环向量
- flutter - 我已删除 Pub\Cache\hosted\pub.dartlang.org 文件夹以更新颤振包,但在颤振包中显示错误获取
- python - 集成终端停止在 Visual Studio Code 中显示文本
- python-3.x - 即使安装 ffmpeg 也找不到 FFserver 命令
- javascript - 如何从 Map.keys() 中获取排序数组