Maven中的静态html网页

问题描述 投票:3回答:2

我想将静态html网页作为Maven项目。我已经完成了本教程http://www.doclo.be/lieven/articles/personalsitewithmaven.html建议的项目。

我已将具有完整结构的静态html网页复制到src / site / resources目录中,并且删除了src / site目录中的所有文件/目录(而不是资源目录)。

我已在报告部分名为maven-linkcheck-plugin的插件的pom.xml文件中添加了它(其用法在http://maven.apache.org/plugins/maven-linkcheck-plugin/usage.html中进行了说明。]

我想在项目中使用诸如surefire插件之类的工具,如果生成的网页上的链接中有任何错误,则构建失败。 linkcheck插件似乎只检查链接的有效性和tryies来检索所有链接的头部。例如,当引用不存在的pdf文件时,它不会产生任何错误。

要拥有我的项目,只需执行以下操作:

mvn archetype:create -DgroupId=com.mypage -DartifactId=mypage -DarchetypeArtifactId=maven-archetype-site-simple
cd mypage
rm -r src/site/*
mkdir src/site/resources
echo "<h1>my last web page, I promisse</h1> <a href="relativeUrlToNonexistentPage.html">Link text</a>" > src/site/resources/index.html

比编辑pom.xml并添加到那里:

  <reporting>
   <excludeDefaults>true</excludeDefaults>
   <plugins>
    <plugin>
     <groupId>org.apache.maven.plugins</groupId>
     <artifactId>maven-project-info-reports-plugin</artifactId>
     <version>2.7</version>
     <reportSets>
          <reportSet>
           <reports />
          </reportSet>
     </reportSets>
    </plugin>
    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-linkcheck-plugin</artifactId>
        <version>1.1</version>
        <configuration>
          <excludedLinks>
            <excludedLink>https://trackit.sk/app</excludedLink>
          </excludedLinks>
        </configuration>
      </plugin>
   </plugins>
  </reporting>

比刚刚运行:mvn clean网站:运行然后打开http:// localhost:8080网页。在那里,您将看到无效的链接。

[我跑步时:mvn clean linkcheck:linkcheck在目标目录中生成了报告,但没有错误。根据该报告,似乎没有扫描无效的URL链接。

我想通过某个Maven插件检查所有的ulrs(所有相对的就足够了)。是否有可能通过linkcheck插件执行此操作,或者我应该为此使用其他插件?

html maven static
2个回答
0
投票

首先,maven是一个用于库的存储库系统,它基于项目对象模型(即POM),我们在pom.xml中添加了相关性,以便maven应该自动下载项目所需的所有库。您的问题是您想将静态html页面保存为maven项目,但是maven与该页面无关,取决于您如何管理静态资源,因此请查看IDE的文档]


0
投票

当然,您可以使用Maven创建仅包含纯HTML文件的warfile(Web应用程序)。

只需将packaging设置为war,然后将纯HTML文件拖放到src/main/webapp中>

[将yourprojectname.war复制到计算机上的tomcat webapps文件夹中,并且其中一个文件称为example.html,则该文件的URL例如可以是http://localhost:8080/yourprojectname/example.html

有关详细信息,请参阅MavenTomcat文档。

© www.soinside.com 2019 - 2024. All rights reserved.