从命令行运行时Spring Boot Missing插件

时间:2016-06-20 14:22:35

标签: java linux maven spring-boot

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

时,我收到错误

"找不到前缀' spring-boot'在当前项目和插件组中[org.apache.maven.plugins,org.codehaus.mojo]可从存储库中获取"

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

2 个答案:

答案 0 :(得分:1)

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

答案 1 :(得分:0)

您是否尝试过从jar运行应用程序?如果您按照here的说明使用Spring Boot的maven插件,那么您应该能够java -jar your-jar-file.jar,而不需要使用maven。