score:54

Accepted answer
  1. right click your project name.

  2. click properties.

  3. click java build path.

  4. click on add class folder.

  5. then choose your class.

alternatively, add jars should work although you claim that you attempted that.

also, "have you tried turning it off and back on again"? (restart eclipse).

score:0

solved the problem by dropping the jar into web_inf/lib.

score:0

copying the jar files will resolve. if by any chance you are copying the code from any tutorials, make sure the class names are spelled in correct case...for example i copied a code from one of the tutorials which had solr in s cap. eclipse was continiously throwing the error and i also did a bit of googling ...everything was ok and it took 30 mins for me to realise the cap small issue. am sure this will help someone

score:0

for many new users don't forget to add an asterisk (*) after your import statements if you wanna use all the classes in a package....for example

import java.io.*;

public class learning 
{
    public static void main(string[] args) 
    {
        bufferedinputstream sd = new bufferedinputstream(system.in);
            // no error
    }
}

================================================================

import java.io;

public class learning 
{
    public static void main(string[] args) 
    {
        bufferedinputstream sd = new bufferedinputstream(system.in);
            // bufferedinputstream cannot be resolved to a type error
    }
}

score:0

solution : 1.project -> build path -> configure build path

2.select java build path on the left menu, and select "source"

3.under project select include(all) and click ok

cause : the issue might because u might have deleted the class files or dependencies on the project

score:0

project -> build path -> configure build path
select java build path on the left menu, and select "source"
 click on excluded and then include(all) and then click ok
    cause : the issue might because u might have deleted the class files 
 or dependencies on the project

for maven users:

right click on the project

maven

update project

score:0

first you need to update the pom.xml by adding below

    <dependency>
    <groupid>org.springframework</groupid>
    <artifactid>spring-web</artifactid>
    <version>4.1.6.release</version>
    </dependency>

1] right click your project name.

2] click properties.

3] click java build path.

4] check on 'maven dependencies' in order and export tabl.

in my case, previously it was not enabled. so when i enabled it my @getmapping annotation works fine..

score:0

also, there is the solution for ivyde users. right click on project -> ivy -> resolve it's necessary to set ivy.mirror property in build.properties

score:0

i just closed all the files and reopened them, and voila!!! hope this helps someone in the future ;)

score:0

download servlet-api.jar file and paste it in web-inf folder it will work

score:2

  • right click project > properties
  • java build path > add class folder
  • select the bin folder
  • click ok
  • switch order and export tab
  • select the newly added bin path move up
  • click apply button

enter image description here

score:3

easy solution:
go to

project property -> java builder path -> maven -> find c3p0-0.9.5.2.jar

and see the location where the file is stored in the local repository and go to this location and delete the repository manually.

g

score:5

for maven users:

  • right click on the project
  • maven
  • update project

score:7

project -> clean

can at least sometimes be sufficient to resolve the matter.

score:7

there are two ways to solve the issue "cannot be resolved to a type ":

  1. for non maven project, add jars manually in a folder and add it in java build path. this would solve the compilation errors.
  2. for maven project, right click on the project and go to maven -> update project. select all the projects where you are getting compilation errors and also check "force update of snapshots/releases". this will update the project and fix the compilation errors.

score:18

to solve the error "...cannot be resolved to a type.." do the followings:

  1. right click on the class and select "build path-->exclude"
  2. again right click on the class and select "build path-->include"

it works for me.

score:62

also if you are using mavenised project then try to update your project by clicking alt+f5. or right click on the application and go to maven /update project.

it builds all your components and resolves if any import error is there.


Related Query

More Query from same tag