问题描述
Test.java
是具有 main 方法的类
我在 Test.java
中添加了 pom.xml
。以便在maven build之后调用main方法。
下面的代码片段,表示pom.xml
中的类名
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.6.0</version>
<configuration>
<mainClass>com.example.Test</mainClass>
</configuration>
</plugin>
我正在使用 mvn clean install exec:java
命令运行项目。
正如预期的那样,在成功构建 maven 后调用 Test.java
。
即使在 maven 构建失败后,是否还有任何选项可以运行 Test.java
?
解决方法
考虑使用 Java Spring-Boot 命令行运行程序:
@SpringBootApplication
public class SpringBootConsoleApplication
implements CommandLineRunner {
private static Logger LOG = LoggerFactory
.getLogger(SpringBootConsoleApplication.class);
public static void main(String[] args) {
LOG.info("STARTING THE APPLICATION");
SpringApplication.run(SpringBootConsoleApplication.class,args);
LOG.info("APPLICATION FINISHED");
}
@Override
public void run(String... args) {
LOG.info("EXECUTING : command line runner");
for (int i = 0; i < args.length; ++i) {
LOG.info("args[{}]: {}",i,args[i]);
}
}
}
一旦服务器启动,就会调用 public void run()
中的代码。
根据@azbarcea 的评论,尝试将以下代码段添加到 $FirewallList.Count
3
$FirewallList[0]
IpAndPorts Protocol
---------- --------
35.180.0.0/16 TCP
属性
pom.xml
添加上述代码后,<maven.test.failure.ignore>true</maven.test.failure.ignore>
被调用并开始执行。