3
respostas

Aula 5 - Mudando nosso container web

Até o presente momento não consegui fazer com que minha aplicação funcione utilizando o Jetty com as versões 1.5.5 e 1.5.6 do Spring Boot. Somente obtive sucesso com a versão 1.5.4 do Spring Boot.

Se alguém souber o motivo e quiser compartilhar eu agradeço.

At. Winston

3 respostas

Oi, Winston!

Como que está o seu pom.xml configurado para o plugin do Jetty e aparece alguma mensagem de erro?

Olá Arthur. Segue o conteúdo do pom.xml e o log de execução da aplicação.

<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>br.com.alura.listavip</groupId>
    <artifactId>listavip</artifactId>
    <version>1.0.0-SNAPSHOT</version>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
        <spring.version>1.5.6.RELEASE</spring.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
            <version>${spring.version}</version>
            <exclusions>
                <exclusion>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-starter-tomcat</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-jetty</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-thymeleaf</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <version>${spring.version}</version>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>6.0.6</version>
        </dependency>
        <dependency>
            <groupId>br.com.alura.emailsender</groupId>
            <artifactId>emailsender</artifactId>
            <version>1.0.0-SNAPSHOT</version>
        </dependency>
    </dependencies>

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

<!--     <packaging>war</packaging> -->

<!--     <build> -->
<!--         <plugins> -->
<!--             <plugin> -->
<!--                 <groupId>org.apache.maven.plugins</groupId> -->
<!--                 <artifactId>maven-war-plugin</artifactId> -->
<!--                 <version>2.6</version> -->
<!--                 <configuration> -->
<!--                     <failOnMissingWebXml>false</failOnMissingWebXml> -->
<!--                 </configuration> -->
<!--             </plugin> -->
<!--         </plugins> -->
<!--     </build> -->
</project>

Log da aplicação

SLF4J: The requested version 1.7.16 by your slf4j binding is not compatible with [1.6]
SLF4J: See http://www.slf4j.org/codes.html#version_mismatch for further details.
09:56:19.861 [main] DEBUG org.springframework.boot.devtools.settings.DevToolsSettings - Included patterns for restart : []
09:56:19.864 [main] DEBUG org.springframework.boot.devtools.settings.DevToolsSettings - Excluded patterns for restart : [/spring-boot-starter/target/classes/, /spring-boot-autoconfigure/target/classes/, /spring-boot-starter-[\w-]+/, /spring-boot/target/classes/, /spring-boot-actuator/target/classes/, /spring-boot-devtools/target/classes/]
09:56:19.864 [main] DEBUG org.springframework.boot.devtools.restart.ChangeableUrls - Matching URLs for reloading : [file:/home/winston/treinamento/alura/springboot/listavip/target/classes/, file:/home/winston/treinamento/workspace/emailsender/target/classes/]

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v1.5.6.RELEASE)

2017-07-28 09:56:20.143  INFO 16530 --- [  restartedMain] b.c.alura.listavip.ListaVipApplication   : Starting ListaVipApplication on note-winston with PID 16530 (/home/winston/treinamento/alura/springboot/listavip/target/classes started by winston in /home/winston/treinamento/alura/springboot/listavip)
2017-07-28 09:56:20.144  INFO 16530 --- [  restartedMain] b.c.alura.listavip.ListaVipApplication   : No active profile set, falling back to default profiles: default
2017-07-28 09:56:20.393  INFO 16530 --- [  restartedMain] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@2e8013f4: startup date [Fri Jul 28 09:56:20 BRT 2017]; root of context hierarchy
2017-07-28 09:56:22.274  INFO 16530 --- [  restartedMain] j.LocalContainerEntityManagerFactoryBean : Building JPA container EntityManagerFactory for persistence unit 'default'
2017-07-28 09:56:22.286  INFO 16530 --- [  restartedMain] o.hibernate.jpa.internal.util.LogHelper  : HHH000204: Processing PersistenceUnitInfo [
    name: default
    ...]
2017-07-28 09:56:22.361  INFO 16530 --- [  restartedMain] org.hibernate.Version                    : HHH000412: Hibernate Core {5.0.12.Final}
2017-07-28 09:56:22.363  INFO 16530 --- [  restartedMain] org.hibernate.cfg.Environment            : HHH000206: hibernate.properties not found
2017-07-28 09:56:22.364  INFO 16530 --- [  restartedMain] org.hibernate.cfg.Environment            : HHH000021: Bytecode provider name : javassist
2017-07-28 09:56:22.413  INFO 16530 --- [  restartedMain] o.hibernate.annotations.common.Version   : HCANN000001: Hibernate Commons Annotations {5.0.1.Final}
2017-07-28 09:56:22.527  INFO 16530 --- [  restartedMain] org.hibernate.dialect.Dialect            : HHH000400: Using dialect: org.hibernate.dialect.MySQL5Dialect
2017-07-28 09:56:22.900  INFO 16530 --- [  restartedMain] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2017-07-28 09:56:23.985  INFO 16530 --- [  restartedMain] o.s.b.d.a.OptionalLiveReloadServer       : LiveReload server is running on port 35729
2017-07-28 09:56:24.031  INFO 16530 --- [  restartedMain] o.s.j.e.a.AnnotationMBeanExporter        : Registering beans for JMX exposure on startup
2017-07-28 09:56:24.040  INFO 16530 --- [  restartedMain] o.s.c.support.DefaultLifecycleProcessor  : Starting beans in phase 0
2017-07-28 09:56:24.119  INFO 16530 --- [  restartedMain] b.c.alura.listavip.ListaVipApplication   : Started ListaVipApplication in 4.242 seconds (JVM running for 4.899)
2017-07-28 09:56:24.121  INFO 16530 --- [      Thread-10] s.c.a.AnnotationConfigApplicationContext : Closing org.springframework.context.annotation.AnnotationConfigApplicationContext@2e8013f4: startup date [Fri Jul 28 09:56:20 BRT 2017]; root of context hierarchy
2017-07-28 09:56:24.123  INFO 16530 --- [      Thread-10] o.s.c.support.DefaultLifecycleProcessor  : Stopping beans in phase 0
2017-07-28 09:56:24.125  INFO 16530 --- [      Thread-10] o.s.j.e.a.AnnotationMBeanExporter        : Unregistering JMX-exposed beans on shutdown
2017-07-28 09:56:24.126  INFO 16530 --- [      Thread-10] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default'

Prezados,

minha situacao e a mesma, so consegui com a versao 1.5.4.RELEASE.

Eis como esta me pom.xml que consegui:

<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>br.com.alura.listavip</groupId>
    <artifactId>listavip</artifactId>
    <version>0.0.1-SNAPSHOT</version>


    <dependencies>

        <!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-parent -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-parent</artifactId>
            <version>1.5.7.RELEASE</version>
            <type>pom</type>
        </dependency>


        <!-- Dependencia do Spring Boot -->
        <!-- Dependencia responsavel por componentes web -->
        <!-- Tras o container web Tomcat -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
            <!-- Removendo container web default Tomcat para incluirmos o Jetty -->
            <exclusions>
                <exclusion>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-starter-tomcat</artifactId>
                </exclusion>
            </exclusions>
            <version>1.5.7.RELEASE</version>
        </dependency>

        <!-- Incluindo o Jetty como container web default -->
        <!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-jetty -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-jetty</artifactId>
            <version>1.5.4.RELEASE</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-thymeleaf -->
        <!-- Dependencia responsavel pelas rotas -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-thymeleaf</artifactId>
            <version>1.5.7.RELEASE</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-data-jpa -->
        <!-- Dependencia responsavel JPA para persistencia e leitura em banco de 
            dados -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
            <version>1.5.7.RELEASE</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java -->
        <!-- Driver de conexao MySQL -->
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>5.1.39</version>
        </dependency>

        <!-- Stater responsavel a cada alteracao no codigo que a aplicacao que 
            a mesma seja reiniciada automaticamente. -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <version>1.5.7.RELEASE</version>
        </dependency>

        <!-- Incluir a dependencia do projeto de envio de e-mail -->
        <dependency>
            <groupId>br.com.alura.enviadorEmail</groupId>
            <artifactId>enviadorEmail</artifactId>
            <version>0.0.1-SNAPSHOT</version>
        </dependency>

    </dependencies>

</project>

Com a versoa 1.5.7.RELEASE gera erro no meu projeto antes mesmo de rodar o projeto.

Atenciosamente,

Renato Ramos