问题
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