Sin compilador se proporciona en este entorno cuando se genera el proyecto Maven. Error

Hoy en día, cuando se crea un proyecto de construcción Maven "[ERROR] No compilador se proporciona en este entorno. Tal vez se están ejecutando en un JRE en lugar de un JDK?" Estaba muy deprimido, no me encontré con este problema al crear un proyecto común antes ah, ¿por qué crear proyecto Maven Shique creará problemas JDK piensa en él?

El siguiente mensaje de error:


[INFO] Scanning for projects...
[INFO] 
[INFO] -------------------------< Promaven:Promaven >--------------------------
[INFO] Building Promaven 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ Promaven ---
[INFO] Deleting D:\javacode\eclipseworkspaces\Promaven\target
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ Promaven ---
[WARNING] Using platform encoding (GBK actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ Promaven ---
[WARNING] The POM for org.apache.maven:maven-plugin-api:jar:2.2.1 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details
[WARNING] The POM for org.apache.maven:maven-core:jar:2.2.1 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details
[INFO] Changes detected - recompiling the module!
[WARNING] File encoding has not been set, using platform encoding GBK, i.e. build is platform dependent!
[INFO] Compiling 1 source file to D:\javacode\eclipseworkspaces\Promaven\target\classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR : 
[INFO] -------------------------------------------------------------
[ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
[INFO] 1 error
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  0.761 s
[INFO] Finished at: 2020-03-05T20:23:07+08:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project Promaven: Compilation failure
[ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[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

Que no es difícil encontrar dicha información:

[ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?

chino significa:
este entorno no proporciona un compilador. Tal vez está ejecutando JRE en lugar de JDK?

Abra el archivo de configuración en el archivo archivo setting.xml conf nos encontraremos tal descripción:

<!-- profile
     | Specifies a set of introductions to the build process, to be activated using one or more of the
     | mechanisms described above. For inheritance purposes, and to activate profiles via <activatedProfiles/>
     | or the command line, profiles have to have an ID that is unique.
     |
     | An encouraged best practice for profile identification is to use a consistent naming convention
     | for profiles, such as 'env-dev', 'env-test', 'env-production', 'user-jdcasey', 'user-brett', etc.
     | This will make it more intuitive to understand what the set of introduced profiles is attempting
     | to accomplish, particularly when you only have a list of profile id's for debug.
     |
     | This profile example uses the JDK version to trigger activation, and provides a JDK-specific repo.
    <profile>
    

En la penúltima línea de la información anterior se encuentra: Este ejemplo utiliza el JDK perfil versión gatillo se activa, y para proporcionar de reporto una específica de JDK
medios tenemos que especificar una configuración coherente con el entorno JDK
con el fin de hacer lo siguiente:
1, Ventana-> las Preferencias -> Java> instalado JREs-> instalado JRE -> Add -> VM estándar --next.
Aquí Insertar imagen Descripción

2, después de entrar en la pantalla Definición JRE, haga clic en Directorio ... detrás se añadirá automáticamente la elección del directorio de instalación de JDK, puede hacer clic en terminar la
Aquí Insertar imagen Descripciónnota porque he configurado para que la pantalla: el JRE ya está en uso.

3, seleccione el JDK
Aquí Insertar imagen Descripción
4, haga clic en Proyecto -> Construir Path-> Ruta Configurar Construir ...

Aquí Insertar imagen Descripción
5. Seleccione la Vía de construcción Java -> doble clic en el sistema JRE ... -> Cambiar la correspondiente versión de JDK.
Aquí Insertar imagen Descripción6, por lo que el problema está resuelto.

Publicado 32 artículos originales · ganado elogios 24 · vistas 5899

Supongo que te gusta

Origin blog.csdn.net/qq_43663493/article/details/104683227
Recomendado
Clasificación