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 :)

0

There are 0 best solutions below