简体   繁体   English

在创建war / jat时,Maven会忽略资源文件。 如何迫使它包括他们?

[英]Maven is ignoring resource files when creating the war/jat. How to force it to include them?

I am configuring Jenkins (using Maven integration) for the first time. 我是第一次配置Jenkins(使用Maven集成)。 I am liking it but it is not very smooth. 我喜欢它,但不是很顺利。 My project has the following structure 我的项目具有以下结构

Repository 1
  -View
  -Model
  -Business

Repository 2
  -Widget library

In this widget library, I have the following file tree: 在此小部件库中,我具有以下文件树:

  -root
     -src
       -com
         -example
           -file1.java
           -file2.java
           -file3.java
           -widget1.html
           -widget2.html
           -widget3.html

My build gets downloaded, compile and a war is generated. 我的构建被下载,编译并产生了战争。 It also gets deployed to my remote server and I am very happy about it. 它还可以部署到我的远程服务器,对此我感到非常高兴。 Unfortunately, my project still doesn't open because the widget1.html, widget2.html and widget3.html are missing. 不幸的是,由于缺少widget1.html,widget2.html和widget3.html,我的项目仍无法打开。 If I unzip my war file and my WidgetLibrary.jar, the .java classes are included there, but the .html are not. 如果我解压缩战争文件和WidgetLibrary.jar,则会在其中包含.java类,但不会包含.html。

Is there any way to make Maven include all the files in the project? 有什么办法可以使Maven包括项目中的所有文件?

Maven is driven by convention, so I would speculate that the problem is you're not using the Maven standard directory layout . Maven受约定驱动,因此我推测问题是您没有使用Maven 标准目录布局

In general, your project should look like: 通常,您的项目应如下所示:

    src/
        main/
            java/
                com/example/File.java
            resources/
                file.html
        test/
            java/
                com/example/TestFile.java
            resources/
                testResource.txt

This should be invariant of whether it's you or Jenkins building it. 这应该是由您还是由詹金斯(Jenkins)建立。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM