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

Impossível gerar o pacote da aplicação por causa do Enviador de Email

Todas as vezes que eu tento criar o pacote do projeto ListaVIP com o Maven, o seguinte erro de compilação acontece:

[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  4.022 s
[INFO] Finished at: 2020-04-14T03:15:54-03:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project listavip: Compilation failure: Compilation failure: 
[ERROR] /C:/Users/diego/workspace/listavip/src/main/java/br/com/alura/listavip/services/ConvidadoService.java:[12,45] package br.com.alura.enviadorDeEmail.services does not exist
[ERROR] /C:/Users/diego/workspace/listavip/src/main/java/br/com/alura/listavip/services/ConvidadoService.java:[48,21] cannot find symbol
[ERROR]   symbol:   class EmailService
[ERROR]   location: class br.com.alura.listavip.services.ConvidadoService
[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

Qual é a solução para o problema?

5 respostas

Pom do enviadorDeEmail:

<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.2.6.RELEASE</version>
        <relativePath /> <!-- lookup parent from repository -->
    </parent>
    <groupId>br.com.alura</groupId>
    <artifactId>enviadorDeEmail</artifactId>
    <version>1.0.0</version>
    <name>enviadorDeEmail</name>
    <description>Enviador de Email</description>

    <properties>
        <java.version>1.8</java.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter</artifactId>
        </dependency>
        <!-- https://mvnrepository.com/artifact/org.apache.commons/commons-email -->
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-email</artifactId>
            <version>1.5</version>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <groupId>org.junit.vintage</groupId>
                    <artifactId>junit-vintage-engine</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <goals>
                            <goal>repackage</goal>
                            <goal>build-info</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

</project>

Pom do ListaVIP:

<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.2.6.RELEASE</version>
        <relativePath /> <!-- lookup parent from repository -->
    </parent>
    <groupId>br.com.alura</groupId>
    <artifactId>listavip</artifactId>
    <version>1.0.0</version>
    <name>listavip</name>
    <description>Projeto da Lista VIP</description>

    <properties>
        <java.version>1.8</java.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-thymeleaf</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
        </dependency>
        <dependency>
            <groupId>br.com.alura</groupId>
            <artifactId>enviadorDeEmail</artifactId>
            <version>1.0.0</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <groupId>org.junit.vintage</groupId>
                    <artifactId>junit-vintage-engine</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <goals>
                            <goal>build-info</goal>
                            <goal>repackage</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

</project>

Oi Carlos

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project listavip: Compilation failure: Compilation failure: 
[ERROR] /C:/Users/diego/workspace/listavip/src/main/java/br/com/alura/listavip/services/ConvidadoService.java:[12,45] package br.com.alura.enviadorDeEmail.services does not exist
[ERROR] /C:/Users/diego/workspace/listavip/src/main/java/br/com/alura/listavip/services/ConvidadoService.java:[48,21] cannot find symbol
[ERROR]   symbol:   class EmailService
[ERROR]   location: class br.com.alura.listavip.services.ConvidadoService

Pela mensagem de erro, na sua classe ConvidadoService está tentando importar um pacote "br.com.alura.enviadorDeEmail.services", porém esse package não existe no seu projeto.

Exato, mas ele existe no outro projeto, já com o fatjar disponível e tudo. É como se o Eclipse não estivesse "dando visualização" ao outro projeto...

solução!

Os seus pom.xml estão corretos, o ListaVip está referenciando o projeto enviador de e-mail. Nesse caso, talvez você não tenha compilado o enviador de e-mail antes de compilar o ListaVip.

Tenta ir no diretório do enviador de email e rodar

mvn clean install

Depois você tenta rodar novamente no diretório do ListaVip