部署Spring Boot应用程序时出现问题

问题描述

我在部署Spring Boot应用程序时遇到问题。
首先,我尝试将其部署在heroku上,但是出现错误
当我尝试在本地部署它时,出现了相同的错误
就是这样:

 ...
[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

我想这是我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>

我不知道该怎么办。
我将其放在公共存储库中,所以任何敏感数据都不会在那里...
最好的是,我有几乎相同的应用程序
几乎都是相同的pom,一切都很好。
我很困惑。

解决方法

终于我解决了这个问题。
首先,我必须在pom.xml中建立一个存储库

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

比我不得不删除Java版本(从pom.xml中删除)的繁荣。
我已经在应用程序的主文件夹中创建了一个system.properities。
在那里我放了java版本,

java.runtime.version=11

比我只需要简单地'mvn deploy'
然后heroku想要我的应用。
效果很好。