在 wicket 应用程序中访问 Maven 依赖项的资源

Acessing resource of a maven dependency in a wicket application

我有两个 Maven 项目。

components: 包含 wicket 组件。所有这些 wicket 组件都依赖于一个名为 component.css 的样式表。样式表由 libsass-maven-plugin 生成并输出到 projet.build.directory。 (直接进入target文件夹)本项目打包为jar

web-app: 这是打包为 war.

的(wicket)web 应用程序的项目

我的问题是,我找不到将 componet.css 作为外部资源包含在我的 web-app 项目中的方法。

我尝试使用 maven-war-plugin 将其包含到 webapp 文件夹中,并将其作为 <link> 加载到 html 中,但这没有用,因为 components 不是 war 项目。

然后我尝试使用 new CssResourceReference(SomeClass.class, "/component.css") 让 wicket 生成 <link> 元素,但是我得到一个错误,拒绝访问(静态)包资源。

我最后一个可能的解决方案是在 components 中创建一个 class 并生成相对于 class 的 component.css。但不知何故,即使这样也行不通。

Then I tried to use new CssResourceReference(SomeClass.class, "/component.css") to let wicket generate the element, but I get an error that the access to (static) package resource is denied.

这应该有效。 Wicket 的默认设置允许提供 .css 个静态文件 [1]。您是否使用禁用 .css 的自定义 IPackageResourceGuard?

  1. https://github.com/apache/wicket/blob/master/wicket-core/src/main/java/org/apache/wicket/markup/html/PackageResourceGuard.java