Maven Project appears java.lang.ClassNotFoundException

Source: Internet
Author: User

find some information on the Internet, some say is a small jar package, the Spring jar package to copy to/web-inf/lib below the line, but this is the MAVEN project, do not need to do this ...

Another reason is that the project is not a MAVEN project, I was a regular web project, just added a pom.xml .
There are two places that need to be modified

1. project file, open with Notepad, add the following code (put the original < buildspec > nodes and < natures > replaced):

 <buildSpec> <buildCommand> <name>org.eclipse.wst.jsdt.core.javascriptvalidator</na             me> <arguments> </arguments> </buildCommand> <buildCommand> <name>org.eclipse.jdt.core.javabuilder</name> <arguments> </argumen ts> </buildCommand> <buildCommand> <name>org.eclipse.wst.common.project.face        t.core.builder</name> <arguments> </arguments> </buildCommand> <buildCommand> <name>org.eclipse.wst.validation.validationbuilder</name> <argu ments> </arguments> </buildCommand> <buildCommand> <name>or g.eclipse.m2e.core.maven2builder</name> <arguments> </arguments> </build Command> <bUildcommand> <name>org.maven.ide.eclipse.maven2Builder</name> <arguments> </arguments> </buildCommand> </buildSpec> <natures> <nature>org.ma Ven.ide.eclipse.maven2nature</nature> <nature>org.eclipse.m2e.core.maven2Nature</nature> & Lt;nature>org.eclipse.jem.workbench.javaemfnature</nature> <nature> Org.eclipse.wst.common.modulecore.modulecorenature</nature> <nature> Org.eclipse.wst.common.project.facet.core.nature</nature> <nature>org.eclipse.jdt.core.javanature </nature> <nature>org.eclipse.wst.jsdt.core.jsNature</nature> </natures>



2. In the project root directory, locate the. classpath.

<classpathentry kind= "Con" path= "Org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>



to be replaced by:

<classpathentry kind= "Con" path= "Org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER" >    <attributes>        <attribute name= "org.eclipse.jst.component.dependency" value= "/web-inf/lib"/>    </attributes> </classpathentry>



Add a new classpathentry node:

<classpathentry kind= "Con" path= "Org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER" >    <attributes>        <attribute name= "org.eclipse.jst.component.dependency" value= "/web-inf/lib"/> </attributes></    Classpathentry>



OK, to this step is finished, refresh the project into eclipse, then restart Tomcat, the error has been resolved!



in the. classpath file:

<classpathentry kind= "Output" path= "Target/classes"/>



instead:

<classpathentry kind= "Output" path= "Webcontent/web-inf/classes"/>



habit, ^_^, put the compiled file under Web-inf/classes

Maven Project appears java.lang.ClassNotFoundException

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.