spring boot run with eclipse tomcat

697 views java
-5

Hi i'm trying to start spring boot with eclipse tomcat.
but it is fail all of it.
also i searched same issue in here stackoverflow but it was not helped to me.

i'm using eclipse and my plug-in is
- BuildShip Gradle Integration 2.0
- Spring Tools 3 Add-On 3.9.6 RELEASE

and i make my project with spring boot
Type : gradle (BuildShip 2.x)
Packaging : War
Java Version : 8
Language : Java

and here is my build.gradle

buildscript {
    ext {
        springBootVersion = '2.1.0.RELEASE'
    }
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
    }
}


apply plugin: 'java'
apply plugin: 'eclipse-wtp'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
apply plugin: 'war'

group = 'heykj.web'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = 1.8
targetCompatibility = 1.8

repositories {
    mavenCentral()
}

configurations {
    providedRuntime
}

dependencies {
    implementation('org.springframework.boot:spring-boot-starter-web')
    providedRuntime('org.springframework.boot:spring-boot-starter-tomcat')
    testImplementation('org.springframework.boot:spring-boot-starter-test')
    //providedCompile "javax.servlet:javax.servlet-api:4.0.1"
}

and this is my application class

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;

@SpringBootApplication
public class PlusFApplication extends SpringBootServletInitializer {

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

    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
        return application.sources(PlusFApplication.class);
    }

}

and my project facets
enter image description here

i don't understand this is not work.. i think eclipse tomcat can't find Main Class.. and i added servlet-api but it doesn't work.
how can i?

answered question

How are you running your application, and do you have any errors ?

Springboot by default runs on tomcat server so can you please remove the tomcat dependency and run your application once again.

1 Answer

3

Spring Boot has a built in web-server, it is run as a Java executable, so no need for Tomcat.

Simply right click on the PlusFApplication class and Run As -> Spring Boot App

posted this

Have an answer?

JD

Please login first before posting an answer.