简体   繁体   中英

Springboot app not running in port through IntelliJ

I am new to IntelliJ (CE 2022.2, MacOS), have been an eclipse user for past 17 years.

I have a simple spring boot application which imported in IntelliJ.

Now i run the application and console shows

Started ExternalserviceApplication in 1.931 seconds (JVM running for 2.607)

Don't have the port property in application.properties so the app should run in 8080.

But i can't access the application on 8080 and active ports display in mac terminal does not show the process running on 8080.

Same application has been running perfectly through Eclipse on 8080.

I might be missing something simple. Do i have to enable something in IntelliJ?

UPDATE

In some posts i saw the issue could be with the maven dependencies.

So i paste my maven dependencies below.

  <?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.7.3</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>org.saurav</groupId>
    <artifactId>externalservice</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>war</packaging>
    <name>externalservice</name>
    <description>Service responsible for making external calls</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.apache.kafka</groupId>
            <artifactId>kafka-streams</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.kafka</groupId>
            <artifactId>spring-kafka</artifactId>
        </dependency> -->

        <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-test</artifactId>
            <scope>test</scope>
        </dependency>
        <!-- <dependency>
            <groupId>org.springframework.kafka</groupId>
            <artifactId>spring-kafka-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>

Best Regards,

Saurav

Resolved the issue.

It seems IntelliJ does not provide tomcat in the classpath.

So in order to do this we need to modify options in the run configuration and enable " Add dependecies with "provided" scope in the classpath.

I got the hint from this SO post.

Unable to start spring-boot application in IntelliJ Idea

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM