0

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

saurav
  • 5,388
  • 10
  • 56
  • 101
  • There's probably many ways to find out what port IntelliJ is using, but here is one: If the service is running, from the run dashboard where your console output is, you should have an "Actuator" tab, if you click into this and then select the "Mappings" tab, you will be able to see all of the endpoints configured in your application, and hovering over one of these will give you the full url including hostname and port. – Douglas Stead Aug 30 '22 at 13:39
  • is it there in the community edition as well ? I dont see the actuator tab – saurav Aug 30 '22 at 13:44
  • Ah, apologies I was looking at my personal instance, which is Enterprise. While it doesn't answer the question you have asked, are you opposed to simply configuring the port? It would solve your problem. All you need is: server.port = 8080 In your application.properties file. – Douglas Stead Aug 30 '22 at 13:51
  • @DouglasStead thanks for your replies...i tried that already...still it didn't solve the problem – saurav Aug 30 '22 at 14:00
  • By default, before that line of log, there should also be a line saying Tomcat started on some port. Have you tried starting it via other ways, e.g. the Spring Boot Maven Plugin if that's convenient to do, and see if your application is available at port 8080? – IUSR Aug 31 '22 at 04:09
  • That works through command line or through eclipse as i had mentioned in the post...somehow the embedded tomcat server does not start in IntelliJ as the tomcat starting logs are missing there – saurav Aug 31 '22 at 08:10

1 Answers1

1

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

saurav
  • 5,388
  • 10
  • 56
  • 101