Search code examples
javaspringspring-bootheroku

Can not deploy spring boot application to the heroku


I try to deploy my spring boot application on the Heroku . I connect my github to the Heroku and create clearDB for the application. After when deploy success I go to the application. But in the logs of the heroku shows me 2020-02-24T20:00:33.959429+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=POST path="/auth/signin" host=linkedin-search.herokuapp.com request_id=52208cc6-575e-444b-bb45-c3910d49b175 fwd="134.249.164.109" dyno= connect= service= status=503 bytes= protocol=https

My Procfile contains that: web: java -jar target/Linkedin_Search-0.0.1-SNAPSHOT.jar My pom.xml build section is:

 <build>
     <sourceDirectory>src/main/java</sourceDirectory>
        <testSourceDirectory>src/test/java</testSourceDirectory>
        <resources>
            <resource>
                <directory>src/main/resources</directory>
            </resource>
        </resources>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <version>2.2.2.RELEASE</version>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.0</version>
                <configuration>
                    <source>11</source>
                    <target>11</target>
                    <release>11</release>
                </configuration>
            </plugin>
            <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-dependency-plugin</artifactId>
                    <version>3.0.1</version>
                    <executions>
                        <execution>
                            <id>copy-dependencies</id>
                            <phase>package</phase>
                            <goals><goal>copy-dependencies</goal></goals>
                        </execution>
                    </executions>
            </plugin>
        </plugins>
    </build>

I do all as in the tutorial on the Heroku dev center but nothing is works.


Solution

  • According to your logs this is the root cause for your issue:

    2020-02-27T13:58:45.159924+00:00 app[web.1]: no main manifest attribute, in target/Linkedin_Search-0.0.1-SNAPSHOT.jar

    The JAR file you create does not have the Main class specified in its manifest. How to fix this really depends on your build setup. I see you're using spring-boot-maven-plugin which usually detects and sets that attribute for you. You can try to configure it explicitly in that plugins configuration section:

    <plugin>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-maven-plugin</artifactId>
        <version>2.2.2.RELEASE</version>
        <configuration>
            <mainClass>com.example.Main</mainClass> 
        </configuration>
    </plugin>
    

    You could also specify the main class explicitly in your Procfile:

    web: java -cp target/Linkedin_Search-0.0.1-SNAPSHOT.jar com.example.Main