英文:
Springboot Java webapp error : process finished with exit code 0
问题
以下是您的内容的中文翻译:
我的应用程序总是退出,并显示"进程以退出代码0结束"。
我尝试了不同版本的JAVA和Springboot,但每次都遇到相同的问题。
以下是运行输出和POM文件数据:
package com.technik.demotechnik;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class DemotechnikApplication {
public static void main(String[] args) {
SpringApplication.run(DemotechnikApplication.class, args);
System.out.println("Hello, world!");
}
}
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.7.13</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.technik</groupId>
<artifactId>demotechnik</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>demotechnik</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>17</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-mongodb</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<excludes>
<exclude>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
</project>
构建日志:
/Library/Java/JavaVirtualMachines/jdk-19.jdk/Contents/Home/bin/java -ea -Didea.test.cyclic.buffer.size=1048576 -javaagent:/Applications/IntelliJ IDEA CE.app/Contents/lib/idea_rt.jar=64000:/Applications/IntelliJ IDEA CE.app/Contents/bin -Dfile.encoding=UTF-8 -Dsun.stdout.encoding=UTF-8 -Dsun.stderr.encoding=UTF-8 -classpath /Users/nikunjrai/.m2/repository/org/junit/platform/junit-platform-launcher/1.8.2/junit-platform-launcher-1.8.2.jar:/Applications/IntelliJ IDEA CE.app/Contents/lib/idea_rt.jar:/Applications/IntelliJ IDEA CE.app/Contents/plugins/junit/lib/junit5-rt.jar:/Applications/IntelliJ IDEA CE.app/Contents/plugins/junit/lib/junit-rt.jar:/Users/nikunjrai/Documents/work/nikunj/projects/java/demotechnik/target/test-classes:/Users/nikunjrai/Documents/work/nikunj/projects/java/demotechnik/target/classes:/Users/nikunjrai/.m2/repository/org/springframework/boot/spring-boot-starter-data-mongodb/2.7.13/spring-boot-starter-data-mongodb-2.7.13.jar:/Users/nikunjrai/.m2/repository/org/springframework/boot/spring-boot-starter/2.7.13/spring-boot-starter-2.7.13.jar:/Users/nikunjrai/.m2/repository/org/springframework/boot/spring-boot/2.7.13/spring-boot-2.7.13.jar:/Users/nikunjrai/.m2/repository/org/springframework/boot/spring-boot-autoconfigure/2.7.13/spring-boot-autoconfigure-2.7.13.jar:/Users/nikunjrai/.m2/repository/org/springframework/boot/spring-boot-starter-logging/2.7.13/spring-boot-starter-logging-2.7.13.jar:/Users/nikunjrai/.m2/repository/ch/qos/logback/logback-classic/1.2.12/logback-classic-1.2.12.jar:/Users/nikunjrai/.m2/repository/ch/qos/logback/logback-core/1.2.12/logback-core-1.2.12.jar:/Users/nikunjrai/.m2/repository/org/apache/logging/log4j/to-slf4j/2.17.2/log4j-to-slf4j-2.17.2.jar:/Users/nikunjrai/.m2/repository/org/apache/logging/log4j/log4j-api/2.17.2/log4j-api-2.17.2.jar:/Users/nikunjrai/.m2/repository/org/slf4j/jul-to-slf4j/1.
<details>
<summary>英文:</summary>
My app always exit. "process finished with exit code 0".
I tried with different versions of JAVA, Springboot but I get same issue everytime.
Below is the run output and POM file data
package com.technik.demotechnik;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class DemotechnikApplication {
public static void main(String[] args) {
SpringApplication.run(DemotechnikApplication.class, args);
System.out.println("Hello, world!");
}
}
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.7.13</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.technik</groupId>
<artifactId>demotechnik</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>demotechnik</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>17</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-mongodb</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<excludes>
<exclude>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
</project>
Build log
/Library/Java/JavaVirtualMachines/jdk-19.jdk/Contents/Home/bin/java -ea -Didea.test.cyclic.buffer.size=1048576 -javaagent:/Applications/IntelliJ IDEA CE.app/Contents/lib/idea_rt.jar=64000:/Applications/IntelliJ IDEA CE.app/Contents/bin -Dfile.encoding=UTF-8 -Dsun.stdout.encoding=UTF-8 -Dsun.stderr.encoding=UTF-8 -classpath /Users/nikunjrai/.m2/repository/org/junit/platform/junit-platform-launcher/1.8.2/junit-platform-launcher-1.8.2.jar:/Applications/IntelliJ IDEA CE.app/Contents/lib/idea_rt.jar:/Applications/IntelliJ IDEA CE.app/Contents/plugins/junit/lib/junit5-rt.jar:/Applications/IntelliJ IDEA CE.app/Contents/plugins/junit/lib/junit-rt.jar:/Users/nikunjrai/Documents/work/nikunj/projects/java/demotechnik/target/test-classes:/Users/nikunjrai/Documents/work/nikunj/projects/java/demotechnik/target/classes:/Users/nikunjrai/.m2/repository/org/springframework/boot/spring-boot-starter-data-mongodb/2.7.13/spring-boot-starter-data-mongodb-2.7.13.jar:/Users/nikunjrai/.m2/repository/org/springframework/boot/spring-boot-starter/2.7.13/spring-boot-starter-2.7.13.jar:/Users/nikunjrai/.m2/repository/org/springframework/boot/spring-boot/2.7.13/spring-boot-2.7.13.jar:/Users/nikunjrai/.m2/repository/org/springframework/boot/spring-boot-autoconfigure/2.7.13/spring-boot-autoconfigure-2.7.13.jar:/Users/nikunjrai/.m2/repository/org/springframework/boot/spring-boot-starter-logging/2.7.13/spring-boot-starter-logging-2.7.13.jar:/Users/nikunjrai/.m2/repository/ch/qos/logback/logback-classic/1.2.12/logback-classic-1.2.12.jar:/Users/nikunjrai/.m2/repository/ch/qos/logback/logback-core/1.2.12/logback-core-1.2.12.jar:/Users/nikunjrai/.m2/repository/org/apache/logging/log4j/log4j-to-slf4j/2.17.2/log4j-to-slf4j-2.17.2.jar:/Users/nikunjrai/.m2/repository/org/apache/logging/log4j/log4j-api/2.17.2/log4j-api-2.17.2.jar:/Users/nikunjrai/.m2/repository/org/slf4j/jul-to-slf4j/1.7.36/jul-to-slf4j-1.7.36.jar:/Users/nikunjrai/.m2/repository/jakarta/annotation/jakarta.annotation-api/1.3.5/jakarta.annotation-api-1.3.5.jar:/Users/nikunjrai/.m2/repository/org/yaml/snakeyaml/1.30/snakeyaml-1.30.jar:/Users/nikunjrai/.m2/repository/org/mongodb/mongodb-driver-sync/4.6.1/mongodb-driver-sync-4.6.1.jar:/Users/nikunjrai/.m2/repository/org/mongodb/bson/4.6.1/bson-4.6.1.jar:/Users/nikunjrai/.m2/repository/org/mongodb/mongodb-driver-core/4.6.1/mongodb-driver-core-4.6.1.jar:/Users/nikunjrai/.m2/repository/org/mongodb/bson-record-codec/4.6.1/bson-record-codec-4.6.1.jar:/Users/nikunjrai/.m2/repository/org/springframework/data/spring-data-mongodb/3.4.13/spring-data-mongodb-3.4.13.jar:/Users/nikunjrai/.m2/repository/org/springframework/spring-tx/5.3.28/spring-tx-5.3.28.jar:/Users/nikunjrai/.m2/repository/org/springframework/spring-context/5.3.28/spring-context-5.3.28.jar:/Users/nikunjrai/.m2/repository/org/springframework/spring-beans/5.3.28/spring-beans-5.3.28.jar:/Users/nikunjrai/.m2/repository/org/springframework/spring-expression/5.3.28/spring-expression-5.3.28.jar:/Users/nikunjrai/.m2/repository/org/springframework/data/spring-data-commons/2.7.13/spring-data-commons-2.7.13.jar:/Users/nikunjrai/.m2/repository/org/slf4j/slf4j-api/1.7.36/slf4j-api-1.7.36.jar:/Users/nikunjrai/.m2/repository/org/springframework/boot/spring-boot-starter-web/2.7.13/spring-boot-starter-web-2.7.13.jar:/Users/nikunjrai/.m2/repository/org/springframework/boot/spring-boot-starter-json/2.7.13/spring-boot-starter-json-2.7.13.jar:/Users/nikunjrai/.m2/repository/com/fasterxml/jackson/core/jackson-databind/2.13.5/jackson-databind-2.13.5.jar:/Users/nikunjrai/.m2/repository/com/fasterxml/jackson/core/jackson-annotations/2.13.5/jackson-annotations-2.13.5.jar:/Users/nikunjrai/.m2/repository/com/fasterxml/jackson/core/jackson-core/2.13.5/jackson-core-2.13.5.jar:/Users/nikunjrai/.m2/repository/com/fasterxml/jackson/datatype/jackson-datatype-jdk8/2.13.5/jackson-datatype-jdk8-2.13.5.jar:/Users/nikunjrai/.m2/repository/com/fasterxml/jackson/datatype/jackson-datatype-jsr310/2.13.5/jackson-datatype-jsr310-2.13.5.jar:/Users/nikunjrai/.m2/repository/com/fasterxml/jackson/module/jackson-module-parameter-names/2.13.5/jackson-module-parameter-names-2.13.5.jar:/Users/nikunjrai/.m2/repository/org/springframework/boot/spring-boot-starter-tomcat/2.7.13/spring-boot-starter-tomcat-2.7.13.jar:/Users/nikunjrai/.m2/repository/org/apache/tomcat/embed/tomcat-embed-core/9.0.76/tomcat-embed-core-9.0.76.jar:/Users/nikunjrai/.m2/repository/org/apache/tomcat/embed/tomcat-embed-el/9.0.76/tomcat-embed-el-9.0.76.jar:/Users/nikunjrai/.m2/repository/org/apache/tomcat/embed/tomcat-embed-websocket/9.0.76/tomcat-embed-websocket-9.0.76.jar:/Users/nikunjrai/.m2/repository/org/springframework/spring-web/5.3.28/spring-web-5.3.28.jar:/Users/nikunjrai/.m2/repository/org/springframework/spring-webmvc/5.3.28/spring-webmvc-5.3.28.jar:/Users/nikunjrai/.m2/repository/org/springframework/spring-aop/5.3.28/spring-aop-5.3.28.jar:/Users/nikunjrai/.m2/repository/org/projectlombok/lombok/1.18.28/lombok-1.18.28.jar:/Users/nikunjrai/.m2/repository/org/springframework/boot/spring-boot-starter-test/2.7.13/spring-boot-starter-test-2.7.13.jar:/Users/nikunjrai/.m2/repository/org/springframework/boot/spring-boot-test/2.7.13/spring-boot-test-2.7.13.jar:/Users/nikunjrai/.m2/repository/org/springframework/boot/spring-boot-test-autoconfigure/2.7.13/spring-boot-test-autoconfigure-2.7.13.jar:/Users/nikunjrai/.m2/repository/com/jayway/jsonpath/json-path/2.7.0/json-path-2.7.0.jar:/Users/nikunjrai/.m2/repository/net/minidev/json-smart/2.4.11/json-smart-2.4.11.jar:/Users/nikunjrai/.m2/repository/net/minidev/accessors-smart/2.4.11/accessors-smart-2.4.11.jar:/Users/nikunjrai/.m2/repository/org/ow2/asm/asm/9.3/asm-9.3.jar:/Users/nikunjrai/.m2/repository/jakarta/xml/bind/jakarta.xml.bind-api/2.3.3/jakarta.xml.bind-api-2.3.3.jar:/Users/nikunjrai/.m2/repository/jakarta/activation/jakarta.activation-api/1.2.2/jakarta.activation-api-1.2.2.jar:/Users/nikunjrai/.m2/repository/org/assertj/assertj-core/3.22.0/assertj-core-3.22.0.jar:/Users/nikunjrai/.m2/repository/org/hamcrest/hamcrest/2.2/hamcrest-2.2.jar:/Users/nikunjrai/.m2/repository/org/junit/jupiter/junit-jupiter/5.8.2/junit-jupiter-5.8.2.jar:/Users/nikunjrai/.m2/repository/org/junit/jupiter/junit-jupiter-api/5.8.2/junit-jupiter-api-5.8.2.jar:/Users/nikunjrai/.m2/repository/org/opentest4j/opentest4j/1.2.0/opentest4j-1.2.0.jar:/Users/nikunjrai/.m2/repository/org/junit/platform/junit-platform-commons/1.8.2/junit-platform-commons-1.8.2.jar:/Users/nikunjrai/.m2/repository/org/apiguardian/apiguardian-api/1.1.2/apiguardian-api-1.1.2.jar:/Users/nikunjrai/.m2/repository/org/junit/jupiter/junit-jupiter-params/5.8.2/junit-jupiter-params-5.8.2.jar:/Users/nikunjrai/.m2/repository/org/junit/jupiter/junit-jupiter-engine/5.8.2/junit-jupiter-engine-5.8.2.jar:/Users/nikunjrai/.m2/repository/org/junit/platform/junit-platform-engine/1.8.2/junit-platform-engine-1.8.2.jar:/Users/nikunjrai/.m2/repository/org/mockito/mockito-core/4.5.1/mockito-core-4.5.1.jar:/Users/nikunjrai/.m2/repository/net/bytebuddy/byte-buddy/1.12.23/byte-buddy-1.12.23.jar:/Users/nikunjrai/.m2/repository/net/bytebuddy/byte-buddy-agent/1.12.23/byte-buddy-agent-1.12.23.jar:/Users/nikunjrai/.m2/repository/org/objenesis/objenesis/3.2/objenesis-3.2.jar:/Users/nikunjrai/.m2/repository/org/mockito/mockito-junit-jupiter/4.5.1/mockito-junit-jupiter-4.5.1.jar:/Users/nikunjrai/.m2/repository/org/skyscreamer/jsonassert/1.5.1/jsonassert-1.5.1.jar:/Users/nikunjrai/.m2/repository/com/vaadin/external/google/android-json/0.0.20131108.vaadin1/android-json-0.0.20131108.vaadin1.jar:/Users/nikunjrai/.m2/repository/org/springframework/spring-core/5.3.28/spring-core-5.3.28.jar:/Users/nikunjrai/.m2/repository/org/springframework/spring-jcl/5.3.28/spring-jcl-5.3.28.jar:/Users/nikunjrai/.m2/repository/org/springframework/spring-test/5.3.28/spring-test-5.3.28.jar:/Users/nikunjrai/.m2/repository/org/xmlunit/xmlunit-core/2.9.1/xmlunit-core-2.9.1.jar com.intellij.rt.junit.JUnitStarter -ideVersion5 -junit5 @w@/private/var/folders/mx/tyh72g3d09z3m68qkqpns8sr0000gn/T/idea_working_dirs_junit.tmp @/private/var/folders/mx/tyh72g3d09z3m68qkqpns8sr0000gn/T/idea_junit.tmp -socket63999
14:41:45.585 [main] DEBUG org.springframework.test.context.BootstrapUtils - Instantiating CacheAwareContextLoaderDelegate from class [org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate]
14:41:45.596 [main] DEBUG org.springframework.test.context.BootstrapUtils - Instantiating BootstrapContext using constructor [public org.springframework.test.context.support.DefaultBootstrapContext(java.lang.Class,org.springframework.test.context.CacheAwareContextLoaderDelegate)]
14:41:45.629 [main] DEBUG org.springframework.test.context.BootstrapUtils - Instantiating TestContextBootstrapper for test class [com.technik.demotechnik.DemotechnikApplicationTests] from class [org.springframework.boot.test.context.SpringBootTestContextBootstrapper]
14:41:45.641 [main] INFO org.springframework.boot.test.context.SpringBootTestContextBootstrapper - Neither @ContextConfiguration nor @ContextHierarchy found for test class [com.technik.demotechnik.DemotechnikApplicationTests], using SpringBootContextLoader
14:41:45.645 [main] DEBUG org.springframework.test.context.support.AbstractContextLoader - Did not detect default resource location for test class [com.technik.demotechnik.DemotechnikApplicationTests]: class path resource [com/technik/demotechnik/DemotechnikApplicationTests-context.xml] does not exist
14:41:45.645 [main] DEBUG org.springframework.test.context.support.AbstractContextLoader - Did not detect default resource location for test class [com.technik.demotechnik.DemotechnikApplicationTests]: class path resource [com/technik/demotechnik/DemotechnikApplicationTestsContext.groovy] does not exist
14:41:45.646 [main] INFO org.springframework.test.context.support.AbstractContextLoader - Could not detect default resource locations for test class [com.technik.demotechnik.DemotechnikApplicationTests]: no resource found for suffixes {-context.xml, Context.groovy}.
14:41:45.646 [main] INFO org.springframework.test.context.support.AnnotationConfigContextLoaderUtils - Could not detect default configuration classes for test class [com.technik.demotechnik.DemotechnikApplicationTests]: DemotechnikApplicationTests does not declare any static, non-private, non-final, nested classes annotated with @Configuration.
14:41:45.684 [main] DEBUG org.springframework.test.context.support.ActiveProfilesUtils - Could not find an 'annotation declaring class' for annotation type [org.springframework.test.context.ActiveProfiles] and class [com.technik.demotechnik.DemotechnikApplicationTests]
14:41:45.733 [main] DEBUG org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider - Identified candidate component class: file [/Users/nikunjrai/Documents/work/nikunj/projects/java/demotechnik/target/classes/com/technik/demotechnik/DemotechnikApplication.class]
14:41:45.733 [main] INFO org.springframework.boot.test.context.SpringBootTestContextBootstrapper - Found @SpringBootConfiguration com.technik.demotechnik.DemotechnikApplication for test class com.technik.demotechnik.DemotechnikApplicationTests
14:41:45.803 [main] DEBUG org.springframework.boot.test.context.SpringBootTestContextBootstrapper - @TestExecutionListeners is not present for class [com.technik.demotechnik.DemotechnikApplicationTests]: using defaults.
14:41:45.803 [main] INFO org.springframework.boot.test.context.SpringBootTestContextBootstrapper - Loaded default TestExecutionListener class names from location [META-INF/spring.factories]: [org.springframework.boot.test.mock.mockito.MockitoTestExecutionListener, org.springframework.boot.test.mock.mockito.ResetMocksTestExecutionListener, org.springframework.boot.test.autoconfigure.restdocs.RestDocsTestExecutionListener, org.springframework.boot.test.autoconfigure.web.client.MockRestServiceServerResetTestExecutionListener, org.springframework.boot.test.autoconfigure.web.servlet.MockMvcPrintOnlyOnFailureTestExecutionListener, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverTestExecutionListener, org.springframework.boot.test.autoconfigure.webservices.client.MockWebServiceServerTestExecutionListener, org.springframework.test.context.web.ServletTestExecutionListener, org.springframework.test.context.support.DirtiesContextBeforeModesTestExecutionListener, org.springframework.test.context.event.ApplicationEventsTestExecutionListener, org.springframework.test.context.support.DependencyInjectionTestExecutionListener, org.springframework.test.context.support.DirtiesContextTestExecutionListener, org.springframework.test.context.transaction.TransactionalTestExecutionListener, org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener, org.springframework.test.context.event.EventPublishingTestExecutionListener]
14:41:45.819 [main] INFO org.springframework.boot.test.context.SpringBootTestContextBootstrapper - Using TestExecutionListeners: [org.springframework.test.context.web.ServletTestExecutionListener@1863d2fe, org.springframework.test.context.support.DirtiesContextBeforeModesTestExecutionListener@1787bc24, org.springframework.test.context.event.ApplicationEventsTestExecutionListener@544d57e, org.springframework.boot.test.mock.mockito.MockitoTestExecutionListener@55c53a33, org.springframework.boot.test.autoconfigure.SpringBootDependencyInjectionTestExecutionListener@53b7f657, org.springframework.test.context.support.DirtiesContextTestExecutionListener@797b0699, org.springframework.test.context.transaction.TransactionalTestExecutionListener@5a37d3ed, org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener@26df6e3a, org.springframework.test.context.event.EventPublishingTestExecutionListener@4a3631f8, org.springframework.boot.test.mock.mockito.ResetMocksTestExecutionListener@6b58b9e9, org.springframework.boot.test.autoconfigure.restdocs.RestDocsTestExecutionListener@f14a7d4, org.springframework.boot.test.autoconfigure.web.client.MockRestServiceServerResetTestExecutionListener@52e7a6b2, org.springframework.boot.test.autoconfigure.web.servlet.MockMvcPrintOnlyOnFailureTestExecutionListener@29a5f4e7, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverTestExecutionListener@79c97cb, org.springframework.boot.test.autoconfigure.webservices.client.MockWebServiceServerTestExecutionListener@2d9caaeb]
14:41:45.822 [main] DEBUG org.springframework.test.context.support.AbstractDirtiesContextTestExecutionListener - Before test class: context [DefaultTestContext@34f6515b testClass = DemotechnikApplicationTests, testInstance = [null], testMethod = [null], testException = [null], mergedContextConfiguration = [WebMergedContextConfiguration@4b34fff9 testClass = DemotechnikApplicationTests, locations = '{}', classes = '{class com.technik.demotechnik.DemotechnikApplication}', contextInitializerClasses = '[]', activeProfiles = '{}', propertySourceLocations = '{}', propertySourceProperties = '{org.springframework.boot.test.context.SpringBootTestContextBootstrapper=true}', contextCustomizers = set[org.springframework.boot.test.context.filter.ExcludeFilterContextCustomizer@5aebe890, org.springframework.boot.test.json.DuplicateJsonObjectContextCustomizerFactory$DuplicateJsonObjectContextCustomizer@1190200a, org.springframework.boot.test.mock.mockito.MockitoContextCustomizer@0, org.springframework.boot.test.web.client.TestRestTemplateContextCustomizer@37271612, org.springframework.boot.test.autoconfigure.actuate.metrics.MetricsExportContextCustomizerFactory$DisableMetricExportContextCustomizer@6f45df59, org.springframework.boot.test.autoconfigure.properties.PropertyMappingContextCustomizer@0, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverContextCustomizerFactory$Customizer@5609159b, org.springframework.boot.test.context.SpringBootTestArgs@1, org.springframework.boot.test.context.SpringBootTestWebEnvironment@31610302], resourceBasePath = 'src/main/webapp', contextLoader = 'org.springframework.boot.test.context.SpringBootContextLoader', parent = [null]], attributes = map['org.springframework.test.context.web.ServletTestExecutionListener.activateListener' -> true]], class annotated with @DirtiesContext [false] with mode [null].
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.7.13)
2023-06-27 14:41:46.253 INFO 25047 --- [ main] c.t.d.DemotechnikApplicationTests : Starting DemotechnikApplicationTests using Java 19.0.2 on Nikunjs-MacBook-Pro-2.local with PID 25047 (started by nikunjrai in /Users/nikunjrai/Documents/work/nikunj/projects/java/demotechnik)
2023-06-27 14:41:46.255 INFO 25047 --- [ main] c.t.d.DemotechnikApplicationTests : No active profile set, falling back to 1 default profile: "default"
2023-06-27 14:41:46.682 INFO 25047 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data MongoDB repositories in DEFAULT mode.
2023-06-27 14:41:46.690 INFO 25047 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 3 ms. Found 0 MongoDB repository interfaces.
2023-06-27 14:41:47.623 INFO 25047 --- [ main] org.mongodb.driver.client : MongoClient with metadata {"driver": {"name": "mongo-java-driver|sync|spring-boot", "version": "4.6.1"}, "os": {"type": "Darwin", "name": "Mac OS X", "architecture": "x86_64", "version": "12.6"}, "platform": "Java/Oracle Corporation/19.0.2+7-44"} created with settings MongoClientSettings{readPreference=primary, writeConcern=WriteConcern{w=null, wTimeout=null ms, journal=null}, retryWrites=true, retryReads=true, readConcern=ReadConcern{level=null}, credential=null, streamFactoryFactory=null, commandListeners=[], codecRegistry=ProvidersCodecRegistry{codecProviders=[ValueCodecProvider{}, BsonValueCodecProvider{}, DBRefCodecProvider{}, DBObjectCodecProvider{}, DocumentCodecProvider{}, IterableCodecProvider{}, MapCodecProvider{}, GeoJsonCodecProvider{}, GridFSFileCodecProvider{}, Jsr310CodecProvider{}, JsonObjectCodecProvider{}, BsonCodecProvider{}, EnumCodecProvider{}, com.mongodb.Jep395RecordCodecProvider@21c747a]}, clusterSettings={hosts=[localhost:27017], srvServiceName=mongodb, mode=SINGLE, requiredClusterType=UNKNOWN, requiredReplicaSetName='null', serverSelector='null', clusterListeners='[]', serverSelectionTimeout='30000 ms', localThreshold='30000 ms'}, socketSettings=SocketSettings{connectTimeoutMS=10000, readTimeoutMS=0, receiveBufferSize=0, sendBufferSize=0}, heartbeatSocketSettings=SocketSettings{connectTimeoutMS=10000, readTimeoutMS=10000, receiveBufferSize=0, sendBufferSize=0}, connectionPoolSettings=ConnectionPoolSettings{maxSize=100, minSize=0, maxWaitTimeMS=120000, maxConnectionLifeTimeMS=0, maxConnectionIdleTimeMS=0, maintenanceInitialDelayMS=0, maintenanceFrequencyMS=60000, connectionPoolListeners=[], maxConnecting=2}, serverSettings=ServerSettings{heartbeatFrequencyMS=10000, minHeartbeatFrequencyMS=500, serverListeners='[]', serverMonitorListeners='[]'}, sslSettings=SslSettings{enabled=false, invalidHostNameAllowed=false, context=null}, applicationName='null', compressorList=[], uuidRepresentation=JAVA_LEGACY, serverApi=null, autoEncryptionSettings=null, contextProvider=null}
2023-06-27 14:41:47.635 INFO 25047 --- [localhost:27017] org.mongodb.driver.connection : Opened connection [connectionId{localValue:2, serverValue:81}] to localhost:27017
2023-06-27 14:41:47.635 INFO 25047 --- [localhost:27017] org.mongodb.driver.connection : Opened connection [connectionId{localValue:1, serverValue:80}] to localhost:27017
2023-06-27 14:41:47.635 INFO 25047 --- [localhost:27017] org.mongodb.driver.cluster : Monitor thread successfully connected to server with description ServerDescription{address=localhost:27017, type=STANDALONE, state=CONNECTED, ok=true, minWireVersion=0, maxWireVersion=17, maxDocumentSize=16777216, logicalSessionTimeoutMinutes=30, roundTripTimeNanos=19258901}
2023-06-27 14:41:47.860 INFO 25047 --- [ main] c.t.d.DemotechnikApplicationTests : Started DemotechnikApplicationTests in 2.003 seconds (JVM running for 2.861)
Process finished with exit code 0
It's completely empty app.The main app was not working so I have created a new dummy app to test.this is dummy app my main app is also not working
I am trying to build Rest API app.I am new to JAVA.
</details>
# 答案1
**得分**: 0
I tried your code on my local and it can start successfully without `Process finished with exit code 0`.
我在本地尝试了您的代码,成功启动,没有出现`Process finished with exit code 0`。
I checked your log and I think one possible problem is that your application has NOT been regarded as a web application.
我检查了您的日志,我认为可能的一个问题是您的应用程序没有被视为Web应用程序。
The log ends with
日志以以下内容结尾:
2023-06-27 14:41:47.860 INFO 25047 --- [ main] c.t.d.DemotechnikApplicationTests : Started DemotechnikApplicationTests in 2.003 seconds (JVM running for 2.861)
2023年06月27日 14:41:47.860 INFO 25047 --- [ main] c.t.d.DemotechnikApplicationTests : 在2.003秒内启动了DemotechnikApplicationTests(JVM运行时间为2.861秒)。
So please check whether you are running DemotechnikApplicationTests actually.
因此,请检查您是否实际运行了DemotechnikApplicationTests。
BTW, my local log includes the tomcat, please check whether it is correctly configured.
另外,我的本地日志包括了Tomcat,请检查它是否配置正确。
o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat使用端口初始化:8080(http)
o.apache.catalina.core.StandardService : Starting service [Tomcat]
o.apache.catalina.core.StandardService : 启动服务 [Tomcat]
org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.76]
org.apache.catalina.core.StandardEngine : 启动Servlet引擎:[Apache Tomcat/9.0.76]
o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
o.a.c.c.C.[Tomcat].[localhost].[/] : 初始化Spring嵌入式WebApplicationContext
<details>
<summary>英文:</summary>
Sorry I do not have authority to comment directly so I add a answer here.
I tried your code on my local and it can start successfully without `Process finished with exit code 0`.
I checked your log and I think one possible problem is that your application has NOT been regarded as a web application.
The log ends with
2023-06-27 14:41:47.860 INFO 25047 --- [ main] c.t.d.DemotechnikApplicationTests : Started DemotechnikApplicationTests in 2.003 seconds (JVM running for 2.861)
So please check whether you are running DemotechnikApplicationTests actually.
BTW, my local log includes the tomcat, please check whether it is correctly configured.
o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
o.apache.catalina.core.StandardService : Starting service [Tomcat]
org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.76]
o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
</details>
# 答案2
**得分**: 0
我犯了一个愚蠢的错误。正如我所说,我是JAVA的新手,这确实是我的第一段代码。
***我在运行包而不是应用程序。***
它只运行测试,以上是输出的内容。
<details>
<summary>英文:</summary>
I made a silly mistake there. As I told I am new to JAVA, this was indeed my first code.
***I was running the package instead of app.***
It just runs the test and that's the output pasted above.
</details>
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论