Spring-boot: java.lang.ClassNotFoundException: org.springframework.dao.DataAccessException

Created on 6 Nov 2014  Â·  12Comments  Â·  Source: spring-projects/spring-boot

When 'org.springframework.boot:spring-boot-starter-web' dependency is only added and

run the following code:

@EnableAutoConfiguration
@ComponentScan
public class Application {

    public static void main(String[] args) {
        SpringApplication.run(Application.class);
    }

}

Got the following exception:

java.lang.ClassNotFoundException: org.springframework.dao.DataAccessException

I think there's no reason to get the above exception.

invalid

Most helpful comment

Well, maybe you should have :)

Here's the exception you have in the logs

Caused by: java.lang.IllegalStateException: Could not evaluate condition owing to internal class not found. This can happen if you are @ComponentScanning a springframework package (e.g. if you put a @ComponentScan in the default package by mistake)

All 12 comments

Which Spring Boot version are you using? I couldn't reproduce. Do you have any other component in the package were you defined this app?

I'm using 1.2.0.M2. It occurred even when there's no component.

I still can't reproduce. Please attach a real project. Here's what I did, go on start.spring.io, select 1.2.0.M2, select "web", copy/paste the code above and run. It works

I didn't use Spring Initializer. I shared the project at:

https://github.com/izeye/SpringBootTest

Well, maybe you should have :)

Here's the exception you have in the logs

Caused by: java.lang.IllegalStateException: Could not evaluate condition owing to internal class not found. This can happen if you are @ComponentScanning a springframework package (e.g. if you put a @ComponentScan in the default package by mistake)

Oh, sorry. I didn't understand the logs before you mentioned it.

Now I got it. Thanks :+1:

@snicoll Thank you very much

:+1:

Hi, I have the very similar issue in the latest version of Spring boot

As I told you on stackoverflow already, you probably have one class in the _default_ package that has component scan (_defaut_ package = no package statement in the class). If that's not the case, please create a separate issue with a sample project that reproduces the problem.

I have created new issue #3850 with details. Please check if that is issue or not and close it.

I also have this problem do you resolve it 。 please tell me thanks

Was this page helpful?
0 / 5 - 0 ratings