【问题标题】:Plugin org.springframework.boot:spring-boot-maven-plugin?插件 org.springframework.boot:spring-boot-maven-plugin?
【发布时间】:2019-02-07 16:32:42
【问题描述】:

当我的 spring-boot 代码执行时,我得到如下错误:

未能执行目标 org.springframework.boot:spring-boot-maven-plugin:2.1.2.RELEASE:run (default-cli) on project projectName: 找不到合适的主类,请添加'mainClass ' 属性

我该如何解决这个问题?

【问题讨论】:

  • 你的项目中是否有一个包含 main 方法的类?您介意发布您的包结构并指向包含 main 方法的类吗?

标签: java spring-boot


【解决方案1】:

在插件配置中添加一个主类

<build>
  ...
  <plugins>
    ...
    <plugin>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-maven-plugin</artifactId>
      <configuration>
        <mainClass>your.class.with.main.Method</mainClass>
      </configuration>
    </plugin>
    ...
  </plugins>
  ...
</build>

来源:https://docs.spring.io/spring-boot/docs/current/maven-plugin/usage.html

【讨论】:

    猜你喜欢
    • 2021-10-30
    • 2021-06-27
    • 2023-03-17
    • 2020-04-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-07-12
    • 2023-03-05
    相关资源
    最近更新 更多