英文:
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: 这是(Wicket)Web应用程序的项目,打包为一个war文件。
我的问题是,我找不到一种在我的web-app项目中将component.css
作为外部资源包含的方法。
我尝试过使用maven-war-plugin将其包含到webapp文件夹中,并在HTML中将其作为<link>
加载,但这并不起作用,因为components不是一个war项目。
然后我尝试使用new CssResourceReference(SomeClass.class, "/component.css")
来让Wicket生成<link>
元素,但我得到一个错误,说访问(静态)包资源被拒绝。
我最后的可能解决方案是在components内部创建一个类,并相对于该类生成component.css
。但不知何故,即使这样也不起作用。
英文:
I have two maven projects.
components: Contains wicket components. All of these wicket components rely on a single stylesheet called component.css
. The stylesheet is generated by the libsass-maven-plugin and output to the projet.build.directory
. (Directly into the target folder) This project is packaged as a jar.
web-app: This is the project for the (wicket) web application packaged as a war.
My problem is, that I just can't find a way to include the componet.css
as a external resource in my web-app project.
I tried to include it into the webapp folder using the maven-war-plugin and loading it as a <link>
inside the html, but that didn't work, because components isn't a war project.
Then I tried to use new CssResourceReference(SomeClass.class, "/component.css")
to let wicket generate the <link>
element, but I get an error that the access to (static) package resource is denied.
My last possible solution was to create a class inside components and generate the component.css
relative to that class. But somehow even this isn't working.
答案1
得分: 1
然后我尝试使用新的
CssResourceReference(SomeClass.class, "/component.css")
来让 Wicket 生成<link>
元素,但是我得到了一个错误,说访问(静态)包资源被拒绝。这应该是可以工作的。Wicket 的默认设置允许提供
.css
静态文件 [1]。您是否使用了自定义的IPackageResourceGuard
来禁用了.css
文件?
英文:
> Then I tried to use new CssResourceReference(SomeClass.class, "/component.css") to let wicket generate the <link> element, but I get an error that the access to (static) package resource is denied.
This should work. Wicket's default settings allow .css
static files to be served [1]. Do you use a custom IPackageResourceGuard that disables .css
?
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论