简体   繁体   English

Maven JSP taglib原型

[英]Maven JSP taglib archetype

I am creating a custom JSP tag. 我正在创建一个自定义JSP标记。 It's quite easy to write the Java class, as well as defining the TLD. 编写Java类以及定义TLD非常容易。

My problem is that I don't know how to configure Maven to build a proper JAR file. 我的问题是我不知道如何配置Maven来构建一个合适的JAR文件。 I want to use my tag in other web applications as a Maven dependency. 我想在其他Web应用程序中使用我的标记作为Maven依赖项。 Perhaps JAR packaging isn't the best. 也许JAR包装不是最好的。 How can I achieve this? 我怎样才能做到这一点?

Typically, running: 通常,运行:

mvn package

Will compile your code and generate a 'proper' JAR file that can then be used by other projects. 将编译您的代码并生成一个“适当的”JAR文件,然后由其他项目使用。

More likely, you are wondering how this new JAR file can be added to other Maven projects by simply adding a dependency in the POM file. 更有可能的是,您想知道如何通过在POM文件中添加依赖项将这个新的JAR文件添加到其他Maven项目中。 In order to accomplish this, you will need to place your project's JAR and POM file in a repository. 为了实现此目的,您需要将项目的JAR和POM文件放在存储库中。 This repository can be the local repository on your machine (in which case any one else will have to also install the package) or in some online repository (perhaps using a tool like Artifactory to maintain your own). 此存储库可以是您计算机上的本地存储库(在这种情况下,任何其他人也必须安装该程序包)或某些在线存储库(可能使用Artifactory之类的工具来维护您自己的存储库)。

If you have access to an online repository, you use the distributionManagement part of the POM to specify it and then run: 如果您有权访问在线存储库,则使用POM的distributionManagement部分指定它,然后运行:

mvn deploy

To deploy to it. 部署到它。

To install your project in your local repository use: 要在本地存储库中安装项目,请使用:

mvn install

For more, dealing specifically with custom JSP tags using Maven, see this JSP custom tag example . 有关使用Maven专门处理自定义JSP标记的更多信息,请参阅此JSP自定义标记示例

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

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