Eclipse - Wicket - 未找到依赖项目的 HTML 文件

发布于 2024-12-01 11:41:58 字数 679 浏览 1 评论 0原文

我想在 Eclipse 中构建一个可重用的 Wicket 组件。我有一个项目“组件”,其中包含 MyComponent.java 和 MyComponent.html 等文件。然后我有一个项目“应用程序”,其中包含我的应用程序代码,我希望从中使用 MyComponent。

但是,Wicket 找不到 MyComponent.html。如果我将此文件从“组件”复制到“应用程序”,并使用完全相同的路径,那么 Wicket 发现它没有问题。

因此,我总结说 Eclipse 不会从依赖项目“组件”中复制 HTML 文件并将其提供给 Web 应用程序。我无法真正确认这一点,因为我不知道“组件”项目在哪里生成 JAR,也不知道“应用程序”项目在哪里/是否生成 WAR。

我查看了“组件”中的项目设置,找不到任何在项目构建时显式发布 HTML(非 Java)文件的选项;但我也找不到任何明确禁止这样做的选项。在“应用程序”项目中,我找不到包含其他项目中的 HTML 文件的选项(只有包含 JAR 的选项 - 这可能就足够了?)

更新: 我没有使用 Maven ,只需使用 Eclipse 的默认构建过程即可。

更新:我在 Eclipse 中使用 Tomcat(但没有任何适用于 Tomcat 的 Eclipse 插件;没有它似乎也可以正常工作 - 只是显然这并不完全正确,因此我的问题......)

I want to build a reusable Wicket component in Eclipse. I have one project "components" which have files such as MyComponent.java and MyComponent.html. Then I have a project "application" which contains my application code, from which I wish to use a MyComponent.

However, Wicket cannot find the MyComponent.html. If I copy this file from "components" to "application", and use exactly the same path, then Wicket finds it no problem.

I therefore summize that Eclipse is not copying the HTML file from the dependent project "components" and making it available to the web application. I cannot really confirm that as I don't know where the JAR is being generated from the "components" project, nor do I know where/if the WAR is being generated from the "application" project.

I have looked at the project settings in "components" and cannot find any option to explicitly publish HTML (non-Java) files when the project is being built; but I cannot find any option which is explicitly forbidding this either. In the "application" project I find no option to include HTML files from the other project (there is only the option to include the JAR - which potentially should be enough?)

Update: I am not using Maven, just using the default build process of Eclipse.

Update: I am using Tomcat within Eclipse (but without any Eclipse plug-in for Tomcat; it seems to work fine without it - only obviously that's not quite true hence my question...)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

半岛未凉 2024-12-08 11:41:58

检查 Eclipse 的源文件夹包含/排除过滤器。项目->右键->属性-> Java构建路径->选项卡来源 ->选择源文件夹->按钮编辑。

Check Eclipse's source folders inclusion/exclusion filters. Project -> right button -> Properties -> Java Build path -> tab Source -> select Source Folder -> button Edit.

峩卟喜欢 2024-12-08 11:41:58

我假设您正在使用 Tomcat - 在测试期间我通常使用 Tomcat 上下文来引用我的 Eclipse 项目工作区。
工作区包含一个 context/WEB-INF 目录结构,我编译的所有类、属性、HTML 和其他资源都复制到其中。
Tomcat 上下文文件位于目录 (Tomcat)/conf/Catalina/localhost 中,并包含以下格式的条目:

<Context path="/mywebapp" docBase="C:/eclipse/workspace/myapp/context" reloadable="true">

I'm assuming you're using Tomcat - during testing I normally use a Tomcat context to reference my Eclipse project workspace.
The workspace contains a context/WEB-INF directory structure, into which all my compiled classes, properties, HTML and other resources are copied.
The Tomcat context file lives in the directory (Tomcat)/conf/Catalina/localhost and contains an entry of the following format:

<Context path="/mywebapp" docBase="C:/eclipse/workspace/myapp/context" reloadable="true">
分开我的手 2024-12-08 11:41:58

好的 - 经典 Eclipse 操作 - 由于其他原因(重新启动项目总是导致 404,没有明显的原因:我检查了所有配置文件,一切似乎都很好..),我从 Eclipse 中删除了“应用程序”项目,并且 重新创建了它。现在一切正常(HTML 文件可用...)

OK - Classic Eclipse action - for other reasons (restarting the project always resulted in a 404 for no apparent reason: I checked all the config files and everything seemed fine..), I deleted the "application" project from Eclipse and re-created it. Now everything works fine (HTML files are available...)

差↓一点笑了 2024-12-08 11:41:58

我也有同样的问题!经过一段时间的研究,我找到了解决方案!

您需要向 maven 指定它需要包含所有文件,maven 理解这一点的方式是添加下一个命令。

<build>
    <resources>
        <resource>
            <filtering>false</filtering>
            <directory>src/main/resources</directory>
        </resource>
        <resource>
            <filtering>false</filtering>
            <directory>src/main/java</directory>
            <includes>
                <include>**</include>
            </includes>
            <excludes>
                <exclude>**/*.java</exclude>
            </excludes>
        </resource>
    </resources>
</build>

它对我有用,我希望它对有同样问题的人也有用!
我想对于发布这个查询的人来说已经太晚了,但对于有这个问题的你来说却不是!

I had the same problem! After some time doing research I had a solution!

You need to specify to maven that it needs to include all the files, the way how maven understand this is by adding the next command.

<build>
    <resources>
        <resource>
            <filtering>false</filtering>
            <directory>src/main/resources</directory>
        </resource>
        <resource>
            <filtering>false</filtering>
            <directory>src/main/java</directory>
            <includes>
                <include>**</include>
            </includes>
            <excludes>
                <exclude>**/*.java</exclude>
            </excludes>
        </resource>
    </resources>
</build>

It worked for me, I hope it works for any of you that have the same problem!
I guess for the person that posted this query its too late, but not for you that have this problem!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文