Partage
  • Partager sur Facebook
  • Partager sur Twitter

Blocage du "Hello world" avec Spring boot

Cours de Romain Sessa, Partie 2.4. Écrivez votre premier Hello World

    16 janvier 2021 à 16:22:54

    Créez une application Java avec Spring Boot

    Hello !

    Je suis bloqué au Maven install par :

    [ERROR] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.188 s <<< FAILURE! - in com.example.demo.HelloSpringBootWordApplicationTests
    [ERROR] com.example.demo.HelloSpringBootWordApplicationTests  Time elapsed: 0.187 s  <<< ERROR!
    java.lang.IllegalStateException: Unable to find a @SpringBootConfiguration, you need to use @ContextConfiguration or @SpringBootTest(classes=...) with your test

    Il doit s'agir de la partie Test mais Romain n'en fait pas du tout état à ce niveau du cours et je ne sais pas du tout à quel endroit et comment  introduire @ContextConfiguration ou @SpringBootTest(classes=...).

    Mon code :

    package com.example.helloworld;
    
    import org.springframework.boot.CommandLineRunner;
    import org.springframework.boot.SpringApplication;
    import org.springframework.boot.autoconfigure.SpringBootApplication;
    
    @SpringBootApplication
    public class HelloSpringBootWordApplication implements CommandLineRunner {
    
        public static void main(String[] args) {
            SpringApplication.run(HelloSpringBootWordApplication.class, args);
        }
    
        @Override
        public void run(String... args) throws Exception {
            // TODO Auto-generated method stub
            System.out.println("Enfin !");
        }
    
    }



    C'est probablement tout simple mais mes quelques recherches web n'ont rien donné de concret. Merci de votre aide.

    Yves

    4 heures plus tard :

    C'est trouvé ! Merci Stackoverflow...

    " The root cause was the package name. The package for my test under the src/test/java was not matching the one under the src/main/java. Once I fixed that it worked."

    -
    Edité par YvesCabon 16 janvier 2021 à 21:19:54

    • Partager sur Facebook
    • Partager sur Twitter

    Blocage du "Hello world" avec Spring boot

    × Après avoir cliqué sur "Répondre" vous serez invité à vous connecter pour que votre message soit publié.
    × Attention, ce sujet est très ancien. Le déterrer n'est pas forcément approprié. Nous te conseillons de créer un nouveau sujet pour poser ta question.
    • Editeur
    • Markdown