Processfinishedwithexitcode1解决办法今天遇到这么⼀个问题。
简单描述⼀下:
⽤Gradle搭建⼀个常⽤的SpringBoot项⽬,但是运⾏时死活报错。运⾏⽇志如下:
家常晚餐宝宝肚兜运⾏SpringBoot后,提⽰信息
春季运动会当时的代码环境为:
Application.java
import org.springframework.boot.WebApplicationType;除夕夜守岁
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.scheduling.annotation.EnableScheduling;
@SpringBootApplication
@EnableScheduling
public class Application {
public static void main(String[] args) {
// 不启动Web服务,只以Jar包形式启动
new SpringApplicationBuilder(Application.class).web(WebApplicationType.NONE).run(args);暑假图片
}
}
plugins {
id 'org.springframework.boot' version '2.0.0.RELEASE'
id 'io.spring.dependency-management' version '1.0.9.RELEASE'
id 'java'
}
group ''
version '1.0-SNAPSHOT'
repositories {
mavenCentral()
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-json'
implementation 'org.springframework.kafka:spring-kafka'
annotationProcessor 'org.springframework.boot:spring-boot-configuration-processor'
testCompile group: 'junit', name: 'junit', version: '4.12'
testCompile('org.springframework.boot:spring-boot-starter-test')
testCompileOnly 'org.projectlombok:lombok:1.18.16'
testAnnotationProcessor 'org.projectlombok:lombok:1.18.16'
//Lombok
compileOnly 'org.projectlombok:lombok:1.18.16'
annotationProcessor 'org.projectlombok:lombok:1.18.16'了凡生意经
//Redis模块
compile group: 'redis.clients', name: 'jedis', version: '2.6.2'
//基础⼯具包
compile group: 'commons-io', name: 'commons-io', version: '2.7'
compile 'commons-net:commons-net:3.6'
compile group: 's', name: 'commons-lang3', version: '3.3.2'
compile 'cn.hutool:hutool-all:5.5.7'
compile 'bird:thumbnailator:0.4.13'
//海康威视lib包
compile fileTree(dir:'lib',include:['*.jar'])
}
排除问题的过程:
进⾏⽇志排查
代码:
import org.springframework.boot.WebApplicationType;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.scheduling.annotation.EnableScheduling;
@SpringBootApplication
@EnableScheduling
public class Application {步态不稳
public static void main(String[] args) {
System.out.println("ss");
网络泡沫/
/ 不启动Web服务,只以Jar包形式启动
new SpringApplicationBuilder(ZhanHuaApplication.class).web(WebApplicationType.NONE).run(args);
System.out.println("ss");
}
}
控制台⽇志
根据上⾯的操作,判断是在加载SpringBoot的时候出错,所以对启动代码进⾏异常捕获代码:
import org.springframework.boot.WebApplicationType;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.scheduling.annotation.EnableScheduling;
@SpringBootApplication
@EnableScheduling
public class Application {
public static void main(String[] args) {
System.out.println("ss");
// 不启动Web服务,只以Jar包形式启动
try {
new SpringApplicationBuilder(ZhanHuaApplication.class).web(WebApplicationType.NONE).run(args);
} catch (Throwable e) {
//异常级别越⼤越好,我之前测试的时候,⽤的是Exception,但是没有⽇志。
e.printStackTrace();
}
System.out.println("ss");
}
}
控制台⽇志
结论:
原来是因为依赖冲突,导致的SpringBoot没有成功启动。解决⽅式就是解决依赖冲突。
很多时候不⼀定是依赖冲突造成的这个问题,可以通过这种思路解决