我想使用命令“ mvn spring-boot:run”,但是我想将其与某些参数一起使用,或者允许我仅使用DemoApplication.java并运行项目而没有任何错误。警告不是问题。
我无法删除另一个名为SecureAppApplication的@SpringBootApplication带注释的文件,也不能更改其内容。 (由严格的教授提供,要求不合理)
这是执行命令后的相关错误消息: mvn spring-boot:run
[ERROR] Failed to execute goal org.springframework.boot:spring-boot-
maven-plugin:2.1.8.RELEASE:run (default-cli) on project myproject:
Execution default-cli of goal org.springframework.boot:spring-boot-
maven-plugin:2.1.8.RELEASE:run failed: Unable to find a single main
class from the following candidates
[com.example1.example1.DemoApplication,
com.example1.example1.secureapp.SecureAppApplication]
这是DemoApplication文件代码:
package com.example1.example1;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.GetMapping;
@SpringBootApplication
public class DemoApplication {
public static void main(String[] args) {
SpringApplication.run(DemoApplication.class, args);
System.out.println("System is working!");
}
}
这是SecureAppApplication.java文件代码:
package com.example1.example1.secureapp;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
@SpringBootApplication
public class SecureAppApplication {
public static void main(String[] args) {
SpringApplication.run(SecureAppApplication.class, args);
}
}
答案 0 :(得分:0)
在命令行中,您可以指定要执行的主类
mvn spring-boot:run -Dstart-class=com.your.package.application.BookApplication