[英]How can I test my Spring-Boot application without inheriting 'spring-boot-starter-parent' module?
[英]I can't create my custom spring-boot starter
我尝试创建spring-boot-starter
。 我用这个 Gradle 文件创建了一个简单的spring-boot module
:
plugins {
id 'org.springframework.boot' version '2.1.3.RELEASE'
id 'java'
}
apply plugin: 'io.spring.dependency-management'
group = 'my.domain'
version = '0.0.1-SNAPSHOT'
dependencies {
implementation 'org.springframework.boot:spring-boot-starter'
compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
annotationProcessor "org.springframework.boot:spring-boot-autoconfigure-processor"
}
还有一类:
@SpringBootApplication
public class ApiSpringBootStarterApplication {
public static void main(String[] args) {
SpringApplication.run(ApiSpringBootStarterApplication.class, args);
}
}
它构建成功。 但是如果我删除ApiSpringBootStarterApplication
类,我会收到一个错误:
* What went wrong:
Execution failed for task ':api-spring-boot-starter:bootJar'.
> Main class name has not been configured and it could not be resolved
从插件中删除org.springframework.boot
。 该插件旨在为您的项目构建可执行的 jar。 如果是初学者,您不需要这样做。
参考: https : //docs.spring.io/spring-boot/docs/current/gradle-plugin/reference/html/
以此类推,如果您使用 maven 和spring-boot-maven-plugin
。
JVM 搜索主类来启动应用程序,没有主类就无法启动应用程序。
为什么要删除 ApiSpringBootStarterApplication ? 是你的主班。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.