我想有一个静态的html网页作为一个maven项目。我已经做了像这个教程http://www.doclo.be/lieven/articles/personalsitewithmaven.html上建议的项目。
我已经将具有完整结构的静态html网页复制到src/site/resources目录中,并且删除了src/site目录(而不是resources dir)中的所有文件/目录。
我已经在报告部分的pom.xml文件中添加了名为maven-linkcheck-plugin的插件(其用法在http://maven.apache.org/plugins/maven-linkcheck-plugin/usage.html上有描述)。
我想在项目中有像surefire plugin这样的东西,如果在生成的网页链接中有任何错误,它将无法构建。链接检查插件似乎只检查链接的有效性,并尝试检索所有链接的头部。例如,当引用不存在的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 site:run,然后打开http:// localhost:8080网页。在那里你会看到链接是不起作用的。
当我运行: mvn clean linkcheck:linkcheck在目标目录中有生成的报告,但没有错误。根据该报告,似乎无效的网址链接没有被扫描。
我想通过一些maven插件检查所有的ulrs (所有相关的就足够了)。有没有可能通过链接检查插件来做到这一点,或者我应该使用一些其他的插件呢?
发布于 2020-02-26 21:43:00
发布于 2014-05-27 20:09:50
首先,maven是一个库的存储库系统,它基于项目对象模型,即POM,我们在pom.xml中添加了依赖项,以便maven可以自动下载项目所需的所有库。您的问题是,您希望将静态html页面保存为maven项目,但maven与该页面无关,这取决于您的ide如何管理静态资源,因此请查看适用于您的IDE的文档。
https://stackoverflow.com/questions/23888939
复制相似问题