简体   繁体   English

将Maven项目包含到NON-MAVEN动态Web应用程序中

[英]Include Maven Project into NON-MAVEN Dynamic Web Application

I've included the Maven based project into my application, added Deployment Assembly which shows that the .jar file gets copied to WEB-INF/lib/ImportedProject.jar . 我已经将基于Maven的项目包含到我的应用程序中,并添加了Deployment Assembly,它显示了.jar文件已复制到WEB-INF/lib/ImportedProject.jar

Problem occurs when imported lib wants to reference the lib that it is using which, apparently, does not get included inside the ImportedProject.jar . 当导入的lib想要引用它正在使用的lib(显然没有包含在ImportedProject.jar

Example: 例:

ImportedProject pom.xml has: ImportedProject pom.xml具有:

    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-api</artifactId>
        <version>1.7.12</version>
    </dependency>

When I add ImportedProject.jar to my Non-Maven project and run it, I get exception: 当我将ImportedProject.jar添加到我的Non-Maven项目中并运行它时,出现异常:

threw exception [Servlet execution threw an exception] with root cause java.lang.ClassNotFoundException: org.slf4j.LoggerFactory

My question is: How to add both that Maven project and its dependencies? 我的问题是:如何添加这两种Maven项目它的依赖?

maven dependency plugin helps to get required project library with it's dependencies. Maven依赖插件可帮助获取所需的项目库及其依赖项。

So, If you would like to add POM based project on NON-POM based project, all you would do is to execute mvn dependency:copy-dependencies command and you will have all dependencies on target/dependencies folder. 因此,如果您想在基于NON-POM的项目上添加基于POM的项目,则只需执行mvn dependency:copy-dependencies命令,您将在target/dependencies文件夹中拥有所有依赖项。 Copy all jar from dependencies and paste to WEB-INF/lib directory. 将所有jar从依赖项复制并粘贴到WEB-INF/lib目录。

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

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