2

I have just created a Spring Boot application with a generic model/service/dto/controller/repository and wanted to test it for the first time on a mysql database. When I run the application, it offers no errors but closes immediately after running for just a few seconds. My mavin builds are also successes. Here is the log from the run:

 :: Spring Boot ::                (v3.2.0)

2023-12-01T00:48:31.899-06:00  INFO 1456 --- [           main] com.example.backend.BackendApplication   : Starting BackendApplication using Java 19.0.2 with PID 1456 (C:\Users\marie\Downloads\backend\backend\target\classes started by marie in C:\Users\marie\Downloads\backend)
2023-12-01T00:48:31.947-06:00  INFO 1456 --- [           main] com.example.backend.BackendApplication   : No active profile set, falling back to 1 default profile: "default"
2023-12-01T00:48:32.998-06:00  INFO 1456 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode.
2023-12-01T00:48:33.607-06:00  INFO 1456 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 542 ms. Found 1 JPA repository interface.
2023-12-01T00:48:35.159-06:00  INFO 1456 --- [           main] o.hibernate.jpa.internal.util.LogHelper  : HHH000204: Processing PersistenceUnitInfo [name: default]
2023-12-01T00:48:35.354-06:00  INFO 1456 --- [           main] org.hibernate.Version                    : HHH000412: Hibernate ORM core version 6.3.1.Final
2023-12-01T00:48:35.457-06:00  INFO 1456 --- [           main] o.h.c.internal.RegionFactoryInitiator    : HHH000026: Second-level cache disabled
2023-12-01T00:48:36.183-06:00  INFO 1456 --- [           main] o.s.o.j.p.SpringPersistenceUnitInfo      : No LoadTimeWeaver setup: ignoring JPA class transformer
2023-12-01T00:48:36.238-06:00  INFO 1456 --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Starting...
2023-12-01T00:48:36.871-06:00  INFO 1456 --- [           main] com.zaxxer.hikari.pool.HikariPool        : HikariPool-1 - Added connection com.mysql.cj.jdbc.ConnectionImpl@30aec673
2023-12-01T00:48:36.874-06:00  INFO 1456 --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Start completed.
2023-12-01T00:48:36.951-06:00  WARN 1456 --- [           main] org.hibernate.orm.deprecation            : HHH90000025: MySQLDialect does not need to be specified explicitly using 'hibernate.dialect' (remove the property setting and it will be selected by default)
2023-12-01T00:48:38.198-06:00  INFO 1456 --- [           main] o.h.e.t.j.p.i.JtaPlatformInitiator       : HHH000489: No JTA platform available (set 'hibernate.transaction.jta.platform' to enable JTA platform integration)
2023-12-01T00:48:38.270-06:00  INFO 1456 --- [           main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2023-12-01T00:48:38.829-06:00  INFO 1456 --- [           main] com.example.backend.BackendApplication   : Started BackendApplication in 8.444 seconds (process running for 9.385)
2023-12-01T00:48:38.842-06:00  INFO 1456 --- [ionShutdownHook] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default'
2023-12-01T00:48:38.846-06:00  INFO 1456 --- [ionShutdownHook] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Shutdown initiated...
2023-12-01T00:48:38.869-06:00  INFO 1456 --- [ionShutdownHook] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Shutdown completed.

Process finished with exit code 0

Here is also my pom.xml file:

<?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>3.2.0</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.example</groupId>
    <artifactId>backend</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>backend</name>
    <description>Backend</description>
    <properties>
        <java.version>17</java.version>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-tomcat</artifactId>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>com.mysql</groupId>
            <artifactId>mysql-connector-j</artifactId>
            <scope>runtime</scope>
        </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>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-web</artifactId>
            <version>6.1.1</version>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <configuration>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

BackendApplication

package com.example.backend;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class BackendApplication {

    public static void main(String[] args) {
        SpringApplication.run(BackendApplication.class, args);
    }

}

Ive seen different posts about including/excluding the tomcat dependency from pom.xml, but that doesnt work for me either way. I have tried removing the scope from tomcat. I have tried adding/deleting the 'spring-boot-starter-web' dependency. I have tried a variety of different dependencies and dependency combinations, but none work. I feel like I have tried all the solutions online but none are working. If anyone has any ideas, please let me know :)

5
  • 1
    Could you share the com.example.backend.BackendApplication class content ? By the way, is it normal that you specify the spring-web dependency version in your pom.xml ? It should be handled by the dependency management from spring-boot-starter-parent Commented Dec 1, 2023 at 8:15
  • 1
    @LaurentSchoelens I have updated with my BackendApplication file. Im not sure if it is normal, but the run does not change when I have/delete it. Commented Dec 3, 2023 at 6:37
  • Do you have all the logs output to console and not filtering some logs ? It's strange that it shutdown just after the start... Commented Dec 3, 2023 at 8:12
  • try to put spring logs to trace so you can check what spring tell you Commented Dec 3, 2023 at 8:50
  • debug=true in application.properties. Commented Oct 30, 2024 at 11:27

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.