TomCat does not activate Spring boot. How do you activate it?

1

I'm doing a project using Spring boot in IntelliJ + maven. Following and reading tutorials. I did the step by step but when giving Run the Tom Cat is not demonstrated, activated. I am not using any other server. Below is the code Main + Pom + Controller + RUN

<?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>br.com.xyinc</groupId>
    <artifactId>testex</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>

    <name>poisapp</name>



    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.5.2.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>
        <start-class>mypackage.App</start-class>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-tomcat</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-tomcat</artifactId>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-validator</artifactId>
            <version>5.0.3.Final</version>
        </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>
package br.com.xyinc;

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

@SpringBootApplication
@EnableAutoConfiguration
public class PoisappApplication{

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

}
package br.com.xyinc.controller;

import br.com.xyinc.model.Poi;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


/**
 * Created by Toddy on 10/04/2017.
 */
@RestController
public class PoiController  {

    @RequestMapping("/name")
    public String sayhi(){
        return " Hi ";

    }
}
"C:\Program Files\Java\jdk1.8.0_121\bin\java" -Dserver.port=8090 -XX:TieredStopAtLevel=1 -noverify -Dspring.output.ansi.enabled=always "-javaagent:C:\Program Files (x86)\JetBrains\IntelliJ\lib\idea_rt.jar=55213:C:\Program Files (x86)\JetBrains\IntelliJ\bin" -Dfile.encoding=UTF-8 -classpath "C:\Program Files\Java\jdk1.8.0_121\jre\lib\charsets.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\deploy.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\ext\access-bridge-64.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\ext\cldrdata.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\ext\dnsns.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\ext\jaccess.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\ext\jfxrt.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\ext\localedata.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\ext\nashorn.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\ext\sunec.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\ext\sunjce_provider.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\ext\sunmscapi.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\ext\sunpkcs11.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\ext\zipfs.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\javaws.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\jce.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\jfr.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\jfxswt.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\jsse.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\management-agent.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\plugin.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\resources.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\rt.jar;C:\Users\Toddy\IdeaProjects\poisapp\target\classes;C:\Users\Toddy\.m2\repository\org\springFramework\boot\spring-boot-starter-web.5.2.RELEASE\spring-boot-starter-web-1.5.2.RELEASE.jar;C:\Users\Toddy\.m2\repository\org\springFramework\boot\spring-boot-starter.5.2.RELEASE\spring-boot-starter-1.5.2.RELEASE.jar;C:\Users\Toddy\.m2\repository\org\springFramework\boot\spring-boot.5.2.RELEASE\spring-boot-1.5.2.RELEASE.jar;C:\Users\Toddy\.m2\repository\org\springFramework\boot\spring-boot-autoconfigure.5.2.RELEASE\spring-boot-autoconfigure-1.5.2.RELEASE.jar;C:\Users\Toddy\.m2\repository\org\springFramework\boot\spring-boot-starter-logging.5.2.RELEASE\spring-boot-starter-logging-1.5.2.RELEASE.jar;C:\Users\Toddy\.m2\repository\ch\qos\logback\logback-classic.1.11\logback-classic-1.1.11.jar;C:\Users\Toddy\.m2\repository\ch\qos\logback\logback-core.1.11\logback-core-1.1.11.jar;C:\Users\Toddy\.m2\repository\org\slf4j\jcl-over-slf4j.7.24\jcl-over-slf4j-1.7.24.jar;C:\Users\Toddy\.m2\repository\org\slf4j\jul-to-slf4j.7.24\jul-to-slf4j-1.7.24.jar;C:\Users\Toddy\.m2\repository\org\slf4j\log4j-over-slf4j.7.24\log4j-over-slf4j-1.7.24.jar;C:\Users\Toddy\.m2\repository\org\yaml\snakeyaml.17\snakeyaml-1.17.jar;C:\Users\Toddy\.m2\repository\com\fasterxml\jackson\core\jackson-databind.8.7\jackson-databind-2.8.7.jar;C:\Users\Toddy\.m2\repository\com\fasterxml\jackson\core\jackson-annotations.8.0\jackson-annotations-2.8.0.jar;C:\Users\Toddy\.m2\repository\com\fasterxml\jackson\core\jackson-core.8.7\jackson-core-2.8.7.jar;C:\Users\Toddy\.m2\repository\org\springFramework\spring-web.3.7.RELEASE\spring-web-4.3.7.RELEASE.jar;C:\Users\Toddy\.m2\repository\org\springFramework\spring-aop.3.7.RELEASE\spring-aop-4.3.7.RELEASE.jar;C:\Users\Toddy\.m2\repository\org\springFramework\spring-beans.3.7.RELEASE\spring-beans-4.3.7.RELEASE.jar;C:\Users\Toddy\.m2\repository\org\springFramework\spring-context.3.7.RELEASE\spring-context-4.3.7.RELEASE.jar;C:\Users\Toddy\.m2\repository\org\springFramework\spring-webmvc.3.7.RELEASE\spring-webmvc-4.3.7.RELEASE.jar;C:\Users\Toddy\.m2\repository\org\springFramework\spring-expression.3.7.RELEASE\spring-expression-4.3.7.RELEASE.jar;C:\Users\Toddy\.m2\repository\org\hibernate\hibernate-validator.0.3.Final\hibernate-validator-5.0.3.Final.jar;C:\Users\Toddy\.m2\repository\javax\validation\validation-api.1.0.Final\validation-api-1.1.0.Final.jar;C:\Users\Toddy\.m2\repository\org\jboss\logging\jboss-logging.3.0.Final\jboss-logging-3.3.0.Final.jar;C:\Users\Toddy\.m2\repository\com\fasterxml\classmate.3.3\classmate-1.3.3.jar;C:\Users\Toddy\.m2\repository\org\slf4j\slf4j-api.7.24\slf4j-api-1.7.24.jar;C:\Users\Toddy\.m2\repository\org\springFramework\spring-core.3.7.RELEASE\spring-core-4.3.7.RELEASE.jar" br.com.xyinc.PoisappApplication

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

2017-04-12 19:28:49.287  INFO 10688 --- [           main] br.com.xyinc.PoisappApplication          : Starting PoisappApplication on DESKTOP-2DIKCP9 with PID 10688 (C:\Users\Toddy\IdeaProjects\poisapp\target\classes started by Toddy in C:\Users\Toddy\IdeaProjects\poisapp)
2017-04-12 19:28:49.320  INFO 10688 --- [           main] br.com.xyinc.PoisappApplication          : No active profile set, falling back to default profiles: default
2017-04-12 19:28:50.910  INFO 10688 --- [           main] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@e720b71: startup date [Wed Apr 12 19:28:50 BRT 2017]; root of context hierarchy
2017-04-12 19:29:13.221  INFO 10688 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Registering beans for JMX exposure on startup
2017-04-12 19:29:13.488  INFO 10688 --- [           main] br.com.xyinc.PoisappApplication          : Started PoisappApplication in 35.836 seconds (JVM running for 50.777)
2017-04-12 19:29:13.495  INFO 10688 --- [       Thread-2] s.c.a.AnnotationConfigApplicationContext : Closing org.springframework.context.annotation.AnnotationConfigApplicationContext@e720b71: startup date [Wed Apr 12 19:28:50 BRT 2017]; root of context hierarchy
2017-04-12 19:29:13.498  INFO 10688 --- [       Thread-2] o.s.j.e.a.AnnotationMBeanExporter        : Unregistering JMX-exposed beans on shutdown

Process finished with exit code 0
    
asked by anonymous 13.04.2017 / 00:50

2 answers

1

Inside your pom.xml you should remove the <scope>provided</scope> and then:

<?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>br.com.xyinc</groupId>
    <artifactId>testex</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>

    <name>poisapp</name>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.5.2.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>
        <start-class>mypackage.App</start-class>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-tomcat</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-validator</artifactId>
            <version>5.0.3.Final</version>
        </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>

The scope tag is used to define the dependency scope, if you set it to provided it means that the container will provide dependency, but since you are using Spring Boot without a container, / p>     

13.04.2017 / 01:50
0

I had problems with examples. Tomcat did not work in version 1.5.9.RELEASE:

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

Error

SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.

Solution was to change the version to 1.5.0.RELEASE and it worked perfect.

Tomcat started on port(s): 8080 (http)
Started Demo01Application in 4.829 seconds (JVM running for 5.402)
Initializing Spring FrameworkServlet 'dispatcherServlet'
FrameworkServlet 'dispatcherServlet': initialization started
FrameworkServlet 'dispatcherServlet': initialization completed in 28 ms
    
05.01.2018 / 16:22