【问题标题】:Problem with deploying spring boot application部署spring boot应用程序的问题
【发布时间】:2021-01-14 20:00:01
【问题描述】:

我在部署 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,一切都很好。
我很困惑。

【问题讨论】:

  • 阅读我们收到的错误消息:repository element was not specified in the POM inside distributionManagement element or in -DaltDeploymentRepository=id::layout::url parameter 所以问题是:你想在哪里部署你的.jar
  • 我应该在哪里部署 jar?我怎样才能实现它?
  • 当你告诉 maven 部署一些东西mvn deploy 你应该指定至少一个 maven 应该用来上传你的工件的存储库。在你的情况下,你没有设置任何东西
  • 但是如果我想将它部署到——例如——heroku,该怎么办?在本地它有效。我放置了分发管理,并在存储库上提供了 url file:target/ 。有用。更糟糕的是在线某处部署程序。我不知道在存储库部分要白色什么

标签: spring-boot maven heroku deployment maven-plugin


【解决方案1】:

我终于解决了这个问题。
首先,我必须在 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想要我的应用程序。
工作正常。

【讨论】:

    猜你喜欢
    • 2020-01-09
    • 2020-08-28
    • 1970-01-01
    • 2019-04-30
    • 2019-08-03
    • 2020-06-27
    • 2020-03-05
    • 2017-10-27
    • 2017-09-30
    相关资源
    最近更新 更多