简体   繁体   English

提供范围的Maven依赖的本地用法

[英]Local usage of maven dependency with provided scope

I need to use external framework in my code. 我需要在代码中使用外部框架。 I've added dependency to my pom.xml. 我已经将依存关系添加到我的pom.xml中。 But the problem is that we need to use the same jar across all out project on the remote host, thus we use <scope>provided</scope> And every thing works good if i run my project on the remote host, but when i run it locally i get 但是问题是,我们需要在远程主机上的所有项目上使用相同的jar,因此我们使用<scope>provided</scope>并且如果我在远程主机上运行项目,那么一切都会很好,但是当我我在本地运行

java.lang.NoClassDefFoundError...
...
Caused by: java.lang.ClassNotFoundException:

I've checked - my local repository contains dependency, but still i can't use it. 我已经检查过-我的本地存储库包含依赖项,但仍然无法使用它。 Where should i put my *jar file to make it accessible for my application ? 我应该在哪里放置* jar文件,以便我的应用程序可以访问它?

UPDATE: We use Jetty, but very often we run java code from ruby scripts. 更新:我们使用Jetty,但通常我们从ruby脚本运行Java代码。

You need to make your local environment the same as the one your targeting for production since dependencies with scope 'provided' will not be provided by maven at runtime. 您需要使本地环境与生产目标环境相同,因为maven在运行时不会提供范围为“提供”的依赖项。

You don't say what your using to run your code but assuming you tomcat you could put the .jar file in the shared library directory at $CATALINA_HOME/lib 您没有说您使用什么来运行代码,但是假设您使用的是tomcat,您可以将.jar文件放在$ CATALINA_HOME / lib的共享库目录中

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

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