Search code examples
spring-bootmavenherokudeploymentmaven-plugin

Problem with deploying spring boot application


I have a problem deploying my Spring boot application.
First I tried to deploy it on heroku, but there was an error.
The same error appeared when I was trying to deploy it locally
This is it:

 ...
[INFO] --- maven-surefire-plugin:2.22.2:test (default-test) @ portfolio_app ---
[INFO] 
[INFO] --- maven-jar-plugin:3.2.0:jar (default-jar) @ portfolio_app ---
[INFO] Building jar: C:\JetBrains\portfolio_app\target\portfolio_app-1.0-SNAPSHOT.jar
[INFO] 
[INFO] --- spring-boot-maven-plugin:2.3.3.RELEASE:repackage (repackage) @ portfolio_app ---
[INFO] Replacing main artifact with repackaged archive
[INFO] 
[INFO] --- maven-install-plugin:2.5.2:install (default-install) @ portfolio_app ---
[INFO] Installing C:\JetBrains\portfolio_app\target\portfolio_app-1.0-SNAPSHOT.jar to C:\Users\matni\.m2\repository\eu\mnrdesign\matned\portfolio_app\1.0-SNAPSHOT\portfolio_app-1.0-SNAPSHOT.jar
[INFO] Installing C:\JetBrains\portfolio_app\pom.xml to C:\Users\matni\.m2\repository\eu\mnrdesign\matned\portfolio_app\1.0-SNAPSHOT\portfolio_app-1.0-SNAPSHOT.pom
[INFO] 
[INFO] --- maven-deploy-plugin:2.8.2:deploy (default-deploy) @ portfolio_app ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  4.996 s
[INFO] Finished at: 2020-09-29T10:02:24+02:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.8.2:deploy (default-deploy) on project portfolio_app: Deployment failed: repository element was not specified in the POM inside distributionManagement element or in -DaltDeploymentRepository=id::layout::url parameter -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

I guess it is an issue with my pom:

    <?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>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.3.3.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.group.nden</groupId>
    <artifactId>portfolio_app</artifactId>
    <version>1.0-SNAPSHOT</version>
    <name>portfolio_app</name>
    <description>desc</description>
    <url>http://maven.apache.org</url>
    <properties>
        <java.version>11</java.version>
    </properties>
    <dependencies>
        <!--        SPRING BOOT-->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-security</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-configuration-processor</artifactId>
            <optional>true</optional>
        </dependency>
        <!--        SPRING BOOT-->

        <!--        THYMELEAF-->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-thymeleaf</artifactId>
        </dependency>
        <!-- https://mvnrepository.com/artifact/org.thymeleaf/thymeleaf -->
        <dependency>
            <groupId>org.thymeleaf</groupId>
            <artifactId>thymeleaf</artifactId>
            <version>3.0.11.RELEASE</version>
        </dependency>

        <dependency>
            <groupId>org.thymeleaf.extras</groupId>
            <artifactId>thymeleaf-extras-springsecurity4</artifactId>
            <version>3.0.4.RELEASE</version>
        </dependency>
        <!--        THYMELEAF-->

        <!--        SESSION-->
        <dependency>
            <groupId>org.springframework.session</groupId>
            <artifactId>spring-session-core</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.session</groupId>
            <artifactId>spring-session-jdbc</artifactId>
        </dependency>
        <!--        SESSION-->

        <!--        DATABASE-->
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <scope>runtime</scope>
        </dependency>
        <!--        DATABASE-->
        <!--        PROGRAMING-->
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
        </dependency>
        <!--        PROGRAMING-->

        <!--        VALIDATION-->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-validation</artifactId>
        </dependency>
        <dependency>
            <groupId>javax.validation</groupId>
            <artifactId>validation-api</artifactId>
            <version>2.0.1.Final</version>
        </dependency>
        <!--        VALIDATION-->

        <!--        CAPTCHA-->
        <dependency>
            <groupId>com.google.api-client</groupId>
            <artifactId>google-api-client</artifactId>
            <version>1.30.10</version>
        </dependency>
        <!--        CAPTCHA-->

        <!--         MAIL   -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-mail</artifactId>
            <version>2.2.5.RELEASE</version>
        </dependency>
        <!--         MAIL   -->

        <!--        TESTING-->
        <dependency>
            <groupId>com.github.tomakehurst</groupId>
            <artifactId>wiremock-standalone</artifactId>
            <version>2.26.3</version>
            <scope>test</scope>
        </dependency>
        <!-- https://mvnrepository.com/artifact/org.mockito/mockito-core -->
        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-core</artifactId>
            <version>3.5.10</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <groupId>org.junit.vintage</groupId>
                    <artifactId>junit-vintage-engine</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-test</artifactId>
            <scope>test</scope>
        </dependency>
        <!--        TESTING-->

    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>com.heroku.sdk</groupId>
                <artifactId>heroku-maven-plugin</artifactId>
                <version>3.0.3</version>
            </plugin>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <configuration>
                    <excludes>
                        <exclude>
                            <groupId>org.springframework.boot</groupId>
                            <artifactId>spring-boot-configuration-processor</artifactId>
                        </exclude>
                    </excludes>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

I have no idea what to do.
I put it on a public repository so any sensitive data cannot be there...
The best thing is that I had almost the same application
with mostly the same pom and everything was alright.
I am confused.


Solution

  • Finally I have managed the problem.
    First of all, I had to make a repository in pom.xml

        <distributionManagement>
        <repository>
            <id>myrepository</id>
            <url>file:.mvn/maven-repo</url>
        </repository>
    </distributionManagement>
    

    than i had to delete prosperities with java version (from pom.xml).
    I have created a system.properities in the main folder of my app.
    there I have put java version, this:

    java.runtime.version=11
    

    Than I had to do simply 'mvn deploy'
    Then heroku wanted my app.
    Works fine.