导入包无法解析 [英] The import package cannot be resolved

查看:64
本文介绍了导入包无法解析的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 liferay portlet.我使用 maven 添加了一些外部库.在 ide 中没有错误,它可以识别,但是用 ant 部署时,它说没有这样的包和类

I have a liferay portlet. I've added some external libraries using maven. In ide no errors, it can recognize, but when deploying with ant , it says no such package and class

import pack.SomeClass;
The import pack cannot be resolved

代码:

import pack.SomeClass;
public class MainPortlet extends MVCPortlet {
    public void doView(RenderRequest renderRequest,RenderResponse renderResponse) {
        SomeClass a = new SomeClass();
    }
}

推荐答案

如果你使用的是 maven 并且你已经定义了你的依赖范围为 system 或提供 likeSystem 或提供> 那么它不会包含在部署时生成的 war 文件中或包.

If you are using maven and you have defined your dependency with scope as system or provided likeSystem or provided> then it will not be included in war file generated on deployment or package.

如果您在本地有第三方 jar 并且您想将它们包含在您的 war 文件中,则将该 jar 文件安装到您的本地存储库并从 pom.xml 中删除作用域,然后包 maven 将将该 jar 文件包含在您的 war 中,并且部署时不会出现任何错误

If you have third party jar on local and you want to include them in your war file then install that jar file to your local repository and remove scope from pom.xml then while package maven will include that jar file to your war and you not get any error on deployment

在本地存储库中安装 jar 的命令

Command to install jar in your local repository

mvn install:install-file -Dfile=c:\kaptcha-{version}.jar -DgroupId=com.google.code 
-DartifactId=kaptcha -Dversion={version} -Dpackaging=jar

希望能帮到你!!

这篇关于导入包无法解析的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆