【问题标题】:Spring Boot Missing Plugin when Running from Command Line从命令行运行时 Spring Boot 缺少插件
【发布时间】:2016-06-20 14:22:35
【问题描述】:

我有一个可以在 Eclipse 中运行的 maven 项目,但我无法从 linux 命令行运行它。运行 'mvn spring-boot:run' 时出现错误:

“在当前项目和存储库中可用的插件组 [org.apache.maven.plugins, org.codehaus.mojo] 中找不到前缀“spring-boot”的插件”

这是我的 POM:

<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>
  <groupId>com.example</groupId>
  <artifactId>project</artifactId>
  <version>0.0.1-SNAPSHOT</version>

  <parent>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-parent</artifactId>
      <version>1.3.5.RELEASE</version>
  </parent>

  <repositories>
    <repository>
        <id>spring-releases</id>
        <url>https://repo.spring.io/libs-release</url>
    </repository>
  </repositories>
  <pluginRepositories>
    <pluginRepository>
        <id>spring-releases</id>
        <url>https://repo.spring.io/libs-release</url>
    </pluginRepository>
  </pluginRepositories>

  <dependencies>
      <dependency>
          <groupId>org.springframework.boot</groupId>
          <artifactId>spring-boot-starter-web</artifactId>
      </dependency>
      <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
  </dependencies>

  <properties>
      <java.version>1.8</java.version>
  </properties>


  <build>
      <plugins>
          <plugin>
              <groupId>org.springframework.boot</groupId>
              <artifactId>spring-boot-maven-plugin</artifactId>
               <configuration>
                  <arguments>
                      <argument>--spring.profiles.active=prod</argument>
                  </arguments>
               </configuration>
          </plugin>
      </plugins>
  </build>

</project>

【问题讨论】:

  • 你确定从这个 pom 所在的目录启动命令吗?
  • 直到我最终尝试了完整的命令“mvn org.springframework.boot:spring-boot-maven-plugin:1.3.5.RELEASE:run”,我才知道我应该这样做,这使得错误更改为告诉我我需要从 POM 目录运行命令。我试过了,但现在我又遇到了第三个错误。这很有趣。

标签: java linux maven spring-boot


【解决方案1】:

我最终使用了完整的命令“mvn org.springframework.boot:spring-boot-maven-plugin:1.3.5.RELEASE:run”,当我从包含 pom 的目录中运行它时,由于某种原因它起作用了.xml 文件。

【讨论】:

    【解决方案2】:

    您是否尝试过从 jar 中运行您的应用程序?如果你按照here的解释使用Spring Boot的maven插件,你应该可以java -jar your-jar-file.jar,不需要使用maven。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-10-08
      • 1970-01-01
      • 2020-10-29
      • 1970-01-01
      相关资源
      最近更新 更多