1

when trying to run my first HelloWorld app with springBoot and Tomcat Embeded I get the following exception :

org.springframework.beans.factory.BeanDefinitionStoreException: Failed to read candidate component class nested exception is java.lang.IllegalStateException: Could not evaluate condition on org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration$EmbeddedDatabaseConfiguration due to org/springframework/dao/DataAccessException not found. Make sure your own configuration does not rely on that class. This can also happen if you are @ComponentScanning a springframework package (e.g.
if you put a @ComponentScan in the default package by mistake)

Here is my entry point Example class config:

@SpringBootApplication
public class Example extends SpringBootServletInitializer
{
    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) 
    {
        return application.sources(Example.class);
    }

    public static void main(String[] args) throws Exception 
    {
        SpringApplication.run(Example.class, args);
    }
}

Here is my WelcomeController class:

package controler;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import java.util.Map;

@Controller
public class WelcomeController 
{
    // inject via application.properties
    @Value("${welcome.message:test}")
    private String message = "Hello World";

    @RequestMapping("/")
    public String welcome(Map<String, Object> model) 
    {
        model.put("message", this.message);
        return "welcome";
    }
}

Here is my pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
 <modelVersion>4.0.0</modelVersion>

<groupId>com.springBoot</groupId>
<artifactId>SpringbootHelloword</artifactId>
<version>1.0-SNAPSHOT</version>

 <parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.5.9.RELEASE</version>
 </parent>

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>

    <!-- Tomcat embedded container-->
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-tomcat</artifactId>
        <scope>provided</scope>
    </dependency>

    <!-- JSTL for JSP -->
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>jstl</artifactId>
    </dependency>

    <!-- Need this to compile JSP -->
    <dependency>
        <groupId>org.apache.tomcat.embed</groupId>
        <artifactId>tomcat-embed-jasper</artifactId>
        <scope>provided</scope>
    </dependency>

    <!-- Need this to compile JSP,
        tomcat-embed-jasper version is not working, no idea why -->
    <dependency>
        <groupId>org.eclipse.jdt.core.compiler</groupId>
        <artifactId>ecj</artifactId>
        <version>4.6.1</version>
        <scope>provided</scope>
    </dependency>

    <!-- Optional, test for static content, bootstrap CSS-->
    <dependency>
        <groupId>org.webjars</groupId>
        <artifactId>bootstrap</artifactId>
        <version>3.3.7</version>
    </dependency>

 </dependencies>


</project>
A.Java
  • 39
  • 8
  • refer: https://stackoverflow.com/questions/22771826/beandefinitionstoreexception-failed-to-read-candidate-component-class – Gaurav Feb 13 '18 at 11:52
  • Possible duplicate of [BeanDefinitionStoreException Failed to read candidate component class](https://stackoverflow.com/questions/22771826/beandefinitionstoreexception-failed-to-read-candidate-component-class) – zyexal Feb 13 '18 at 11:54
  • Do you have the data source defined in the application properties file? – Rahul Kargwal Feb 13 '18 at 13:10
  • @RahulKargwal there is no data source in my properties file i have just : spring.mvc.view.prefix: /WEB-INF/jsp/ spring.mvc.view.suffix: .jsp welcome.message: Hello World – A.Java Feb 13 '18 at 13:14
  • There seem to be other files that are not posted here, is that the case? Probably you have defined data source or another bean in any other file? – Rahul Kargwal Feb 13 '18 at 13:28
  • @RahulKargwal absolutly not i just want to make this tutorial : https://www.mkyong.com/spring-boot/spring-boot-hello-world-example-jsp/ – A.Java Feb 13 '18 at 13:40

1 Answers1

0

i changed the server port because it was used by another app and it works correctly.

A.Java
  • 39
  • 8