Solucionado (ver solução)
Solucionado
(ver solução)
4
respostas

mvn compile

Pessoal, criei o primeiro projeto de "produtos" e retornada um erro onde consegui corrigir aplicando:

<properties>
    <!--  compiler settings -->
    <maven.compiler.source>1.6</maven.compiler.source>
    <maven.compiler.target>1.6</maven.compiler.target>
</properties>

Porém, quando fui criar o segundo exemplo do blog, ele retornou o erro: mvn compile WARNING: An illegal reflective access operation has occurred WARNING: Illegal reflective access by com.google.inject.internal.cglib.core.$ReflectUtils$1 (file:/usr/share/maven/lib/guice.jar) to method java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain) WARNING: Please consider reporting this to the maintainers of com.google.inject.internal.cglib.core.$ReflectUtils$1 WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations WARNING: All illegal access operations will be denied in a future release [INFO] Scanning for projects... [INFO] [INFO] ----------------------< .br.com.alura.maven:blog >---------------------- [INFO] Building blog 1.0-SNAPSHOT [INFO] --------------------------------[ jar ]--------------------------------- [INFO] [INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ blog --- [WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent! [INFO] skip non existing resourceDirectory /home/gedan/Documentos/Estudos Alura/blog/src/main/resources [INFO] [INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ blog --- [INFO] Changes detected - recompiling the module! [WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent! [INFO] Compiling 1 source file to /home/gedan/Documentos/Estudos Alura/blog/target/classes [INFO] ------------------------------------------------------------- [ERROR] COMPILATION ERROR : [INFO] ------------------------------------------------------------- [ERROR] /home/gedan/Documentos/Estudos Alura/blog/src/main/java/br/com/alura/maven/App.java:[1,8] <identifier> expected [INFO] 1 error [INFO] ------------------------------------------------------------- [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 1.070 s [INFO] Finished at: 2019-07-28T19:21:02-03:00 [INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project blog: Compilation failure [ERROR] /home/gedan/Documentos/Estudos Alura/blog/src/main/java/br/com/alura/maven/App.java:[1,8] <identifier> expected [ERROR] [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

Então fiz a inclusão da properties como no exemplo anterior e mesmo assim não sai o erro. Como poderia resolver?

4 respostas
solução!

Corrigido. Fiz a inclusão no .pom de acordo com a documentação https://maven.apache.org/plugins/maven-compiler-plugin/usage.html:

 <build>
    <pluginManagement>
      <plugins>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-compiler-plugin</artifactId>
          <version>3.8.1</version>
          <configuration>
            <!-- put your configurations here -->
          </configuration>
        </plugin>
      </plugins>
    </pluginManagement>
  </build>

Oi, Gedan, tudo bom?

No post acima você conseguiu resolver o erro?

Inseria abaixo das dependecias esse codigo:

<build>
   <pluginManagement>
      <plugins>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-compiler-plugin</artifactId>
          <version>3.8.1</version>
          <configuration>
            <!--  compiler settings -->
            <maven.compiler.source>1.8</maven.compiler.source>
            <maven.compiler.target>1.8</maven.compiler.target>
          </configuration>
        </plugin>
      </plugins>
    </pluginManagement>
  </build>

Inseri esse codigo em cima das depencias para poder funcionar para o mvn test

<properties>
    <maven.compiler.target>1.8</maven.compiler.target>
    <maven.compiler.source>1.8</maven.compiler.source>
  </properties>