Alan-Gomes / mcspring-boot

A Spring boot starter for Bukkit/Spigot/PaperSpigot plugins
MIT License
78 stars 25 forks source link

Application not starting with Spring JPA #39

Open Cylop opened 2 years ago

Cylop commented 2 years ago

I am trying to create the presistence layer via Spring JPA but when I try to start the application the error below is thrown. If I start the module with the Spring part on its own, everything is working.

Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'entityManagerFactory' available [18:05:44] [Server thread/WARN]: at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanDefinition(DefaultListableBeanFactory.java:863) [18:05:44] [Server thread/WARN]: at org.springframework.beans.factory.support.AbstractBeanFactory.getMergedLocalBeanDefinition(AbstractBeanFactory.java:1344) [18:05:44] [Server thread/WARN]: at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:309) [18:05:44] [Server thread/WARN]: at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) [18:05:44] [Server thread/WARN]: at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:330)

application.properties is present in resources folder

Main class does look like this:

`

 public class BansPlugin extends JavaPlugin {

private ConfigurableApplicationContext context;

@Override
public void onEnable() {
    saveDefaultConfig();

    try {
        context = SpringSpigotBootstrapper.initialize(this, new SpringApplicationBuilder().bannerMode(Banner.Mode.OFF).sources(BanApplication.class));
    } catch (ExecutionException | InterruptedException e) {
        e.printStackTrace();
    }
}

@Override
public void onDisable() {
    context.close();
    context = null;
}

} `

and the application class does look like this:

@SpringBootApplication public class BanApplication { }

I have no clue why its not working with spigot

Edit:

Dependencies:

implementation 'org.spigotmc:spigot-api:1.18-R0.1-SNAPSHOT' implementation 'org.springframework.boot:spring-boot-starter-data-jpa' runtimeOnly 'mysql:mysql-connector-java' implementation 'dev.alangomes:spigot-spring-boot-starter:0.20.7'