我想将静态 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 插件似乎只检查链接的有效性,并尝试检索所有链接的头部。例如,当引用不存在的 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
Run Code Online (Sandbox Code Playgroud)
比编辑 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>
Run Code Online (Sandbox Code Playgroud)
不仅仅是运行:mvn clean site:run 然后打开 http://localhost:8080 网页。在那里,您将看到无法正常工作的链接。
当我运行时: mvn clean linkcheck:linkcheck 目标目录中有生成的报告,但没有错误。根据报告,似乎没有扫描无效的 url 链接。
我想通过一些 Maven 插件检查所有 ulrs(所有相关的就足够了)。有没有可能通过链接检查插件来做到这一点,或者我应该使用其他插件来做这件事?
Nee*_*rma -3
首先,maven 是一个库的存储库系统,基于项目对象模型(即 POM),我们在 pom.xml 中添加依赖项,以便 maven 应该自动下载项目所需的所有库。你的问题是你想将静态html页面保存为maven项目,但maven与该页面无关,它取决于你的ide如何管理你的静态资源,所以请查看你的IDE的文档
| 归档时间: |
|
| 查看次数: |
2637 次 |
| 最近记录: |