The import package cannot be resolved

你离开我真会死。 提交于 2019-12-13 05:02:56

问题


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

code:

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

回答1:


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.

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

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

Hope it helps!!



来源:https://stackoverflow.com/questions/16664591/the-import-package-cannot-be-resolved

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!