战争构建中缺少包属性文件

发布于 2024-09-12 00:13:31 字数 474 浏览 10 评论 0原文

我的项目中散布着各种位于包中的属性文件,当包目标从 Maven 构建运行时,这些属性文件不会被包含在内。

使用 0.10.2 m2eclipse 插件和默认的“package”目标。

在项目中:

src->main->java->mypackage->MyProperties.java 
src->main->java->mypackage->MyProperties.properties 

在运行“package”目标后扩展的 war 目录中:

target->classes->mypackage->MyProperties.class 

-- 没有属性文件 --

我试图让小组采用 Maven,解决这个问题将成为一个交易撮合者。移动属性文件是不切实际的。非常感谢任何帮助。

Littered throughout my project are various property files located in packages that are not being included when the package goal is run from a Maven build.

Using the 0.10.2 m2eclipse plugin and the default "package" goal.

In the project:

src->main->java->mypackage->MyProperties.java 
src->main->java->mypackage->MyProperties.properties 

In expanded war directory after the "package" goal is run:

target->classes->mypackage->MyProperties.class 

-- no property file --

I'm trying to get the group to adopt Maven and resolving this issue is going to be a deal maker. Moving the properties files isn't going to be practical. Any help is much appreciated.

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

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

发布评论

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

评论(4

分开我的手 2024-09-19 00:13:31

将属性文件放在应用程序/库资源所属的位置,即在 src/main/resources 中:

src/main/resources/mypackage/MyProperties.properties 

它将被正确复制。

Put your property files where Application/Library resources belong, i.e. in src/main/resources:

src/main/resources/mypackage/MyProperties.properties 

And it will get copied properly.

猫七 2024-09-19 00:13:31

Pascal的答案是正确的maven做事方式。

但一些开发人员喜欢将资源放在其来源旁边(例如,这是 wicket 中的标准程序)。

如果您打算这样做,则必须将源文件夹添加到资源中:

<build>
    <resources>
        <resource>
            <directory>src/main/resources</directory>
        </resource>
        <resource>
            <directory>src/main/java</directory>
            <excludes>
                <exclude>**/*.java</exclude>
            </excludes>
        </resource>
    </resources>
</build>

Pascal's answer is the correct maven way of doing things.

But some developers like to keep resources next to their sources (it's standard procedure in wicket, for example).

If you're going to do that, you will have to add your source folder to the resources:

<build>
    <resources>
        <resource>
            <directory>src/main/resources</directory>
        </resource>
        <resource>
            <directory>src/main/java</directory>
            <excludes>
                <exclude>**/*.java</exclude>
            </excludes>
        </resource>
    </resources>
</build>
俯瞰星空 2024-09-19 00:13:31

我帮助检查构建路径。资源的属性被排除在外。当我再次包含它们时,战争从资源中获取了所有属性文件,并且 tomcat 部署正确。

Me helped to check build path. The rpoperties of resources were excluded. When I included them again, the war got all property-files from resource and tomcat deployed correct.

℡寂寞咖啡 2024-09-19 00:13:31

我有同样的问题。解决方案是检查 Eclipse 中项目的构建路径。在“源”中查找“yourProject/src/main/resources”。节点“排除:**”在这里删除过滤器,应用并使用 Maven 再次构建。然后再次启用过滤器并像所有属性文件一样运行。

希望这有帮助

I had same problem. Solution was check Build Path of project at Eclipse. At "source" look for "yourProject/src/main/resources". The node "Excluded: **" here you remove the filter, apply and build again with Maven. Then enable the filter again and runs like a charme with all property-files.

Hope this helps

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