web-dev-qa-db-fra.com

le paquet org.springframework.boot n'existe pas

J'essaie de lancer un petit programme de démarrage Spring sur ma machine et lorsque je lance clean compile (même avant d'essayer spring-boot: run) sur maven, l'erreur suivante apparaît:

[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR : 
[INFO] -------------------------------------------------------------
[ERROR] /C:/Users/hbenayed/Eclipse-workspace/SpringBootPoc/src/main/Java/com/benayed/spboot/poc/SpringBootPoc/SpringBootPocApplication.Java:[3,32] package org.springframework.boot does not exist
[ERROR] /C:/Users/hbenayed/Eclipse-workspace/SpringBootPoc/src/main/Java/com/benayed/spboot/poc/SpringBootPoc/SpringBootPocApplication.Java:[4,46] package org.springframework.boot.autoconfigure does not exist
[ERROR] /C:/Users/hbenayed/Eclipse-workspace/SpringBootPoc/src/main/Java/com/benayed/spboot/poc/SpringBootPoc/SpringBootPocApplication.Java:[6,2] cannot find symbol
  symbol: class SpringBootApplication
[ERROR] /C:/Users/hbenayed/Eclipse-workspace/SpringBootPoc/src/main/Java/com/benayed/spboot/poc/SpringBootPoc/SpringBootPocApplication.Java:[10,17] cannot find symbol
  symbol:   variable SpringApplication
  location: class com.benayed.spboot.poc.SpringBootPoc.SpringBootPocApplication
[INFO] 4 errors 
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 14.807 s
[INFO] Finished at: 2018-02-18T03:28:24+01:00
[INFO] Final Memory: 19M/167M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.Apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project SpringBootPoc: Compilation failure: Compilation failure:
[ERROR] /C:/Users/hbenayed/Eclipse-workspace/SpringBootPoc/src/main/Java/com/benayed/spboot/poc/SpringBootPoc/SpringBootPocApplication.Java:[3,32] package org.springframework.boot does not exist
[ERROR] /C:/Users/hbenayed/Eclipse-workspace/SpringBootPoc/src/main/Java/com/benayed/spboot/poc/SpringBootPoc/SpringBootPocApplication.Java:[4,46] package org.springframework.boot.autoconfigure does not exist
[ERROR] /C:/Users/hbenayed/Eclipse-workspace/SpringBootPoc/src/main/Java/com/benayed/spboot/poc/SpringBootPoc/SpringBootPocApplication.Java:[6,2] cannot find symbol
[ERROR] symbol: class SpringBootApplication
[ERROR] /C:/Users/hbenayed/Eclipse-workspace/SpringBootPoc/src/main/Java/com/benayed/spboot/poc/SpringBootPoc/SpringBootPocApplication.Java:[10,17] cannot find symbol
[ERROR] symbol:   variable SpringApplication
[ERROR] location: class com.benayed.spboot.poc.SpringBootPoc.SpringBootPocApplication
[ERROR] -> [Help 1]
org.Apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.Apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project SpringBootPoc: Compilation failure
    at org.Apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.Java:212)
    at org.Apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.Java:153)
    at org.Apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.Java:145)
    at org.Apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.Java:116)
    at org.Apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.Java:80)
    at org.Apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.Java:51)
    at org.Apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.Java:128)
    at org.Apache.maven.DefaultMaven.doExecute(DefaultMaven.Java:307)
    at org.Apache.maven.DefaultMaven.doExecute(DefaultMaven.Java:193)
    at org.Apache.maven.DefaultMaven.execute(DefaultMaven.Java:106)
    at org.Apache.maven.cli.MavenCli.execute(MavenCli.Java:863)
    at org.Apache.maven.cli.MavenCli.doMain(MavenCli.Java:288)
    at org.Apache.maven.cli.MavenCli.main(MavenCli.Java:199)
    at Sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at Sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.Java:62)
    at Sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.Java:43)
    at Java.lang.reflect.Method.invoke(Method.Java:498)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.Java:289)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.Java:229)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.Java:415)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.Java:356)
Caused by: org.Apache.maven.plugin.compiler.CompilationFailureException: Compilation failure
    at org.Apache.maven.plugin.compiler.AbstractCompilerMojo.execute(AbstractCompilerMojo.Java:858)
    at org.Apache.maven.plugin.compiler.CompilerMojo.execute(CompilerMojo.Java:129)
    at org.Apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.Java:134)
    at org.Apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.Java:207)
    ... 20 more
[ERROR] 
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.Apache.org/confluence/display/MAVEN/MojoFailureException

Voici mon 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.benayed.spboot.poc</groupId>
    <artifactId>SpringBootPoc</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>

    <name>SpringBootPoc</name>
    <description>Demo project for Spring Boot</description>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.5.10.RELEASE</version>
        <relativePath /> <!-- lookup parent from repository -->
    </parent>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <Java.version>1.8</Java.version>
    </properties>

    <dependencies>
        <!-- <dependency> -->
        <!-- <groupId>org.springframework.boot</groupId> -->
        <!-- <artifactId>spring-boot-starter-data-jpa</artifactId> -->
        <!-- </dependency> -->

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

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>
</project>

Et voici ma classe Java:

package com.benayed.spboot.poc.SpringBootPoc;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class SpringBootPocApplication {

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

}

J'ai essayé de nombreuses solutions que je pouvais trouver sur Internet, telles que la suppression du référentiel .m2, l'ajout de différentes balises (version, fork, ...) au plugin spring-boot-maven-plugin qui, j'en suis à peu près sûr, est à l'origine du problème.

Aucune suggestion ?

5
FrankelStein

Vous avez 0 dépendances de compilation, seules les dépendances test-compilation sont définies, car vous avez commenté spring-boot-starter-data-jpa. Les démarreurs Spring attirent d’autres dépendances (y compris d’autres démarreurs) pour créer tout le nécessaire au moment de la compilation. Décommentez la dépendance spring-boot-starter-data-jpa et/ou réexaminez les dépendances que vous souhaitez réellement. 

3
Darren Forsythe

Vous devez ajouter cette dépendance

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

alors ça va marcher.

4
foobarfuu

Ajoutez la section ci-dessous en dehors de la gestion des dépendances et effectuez une mise à jour du projet. Et puis l'installation propre de Maven.

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

Et la dépendance ci-dessous.

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

Si le problème persiste (non susceptible de se produire), ajoutez les autres dépendances mentionnées ici

0
kemparaj565