java.lang.IllegalArgumentException: At least one JPA metamodel must be present

413 views Asked by At

I Integrate the LightAdmin Plugging in my spring boot project,but Run this project throw the Exception. Exception is At least one JPA metamodel must be present. I Basically add the springjpa dependency spring-boot-starter-data-jpa in pom.xml, but again same exception throw. I cannot understand, how to solve these problem Please help ...............!


Pom.xml

<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.javabootstar</groupId>
<artifactId>LightAdminExample</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>

<name>LightAdminExample</name>
<description>Spring Boot With LightAdmin</description>

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.5.4.RELEASE</version>
    <relativePath /> <!-- lookup parent from repository -->
</parent>

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <java.version>1.8</java.version>
</properties>

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-jpa</artifactId>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-devtools</artifactId>
        <scope>runtime</scope>
    </dependency>

    <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <scope>runtime</scope>
    </dependency>

    <!-- https://mvnrepository.com/artifact/org.lightadmin/lightadmin <dependency> 
        <groupId>org.lightadmin</groupId> <artifactId>lightadmin</artifactId> <version>1.0.1.RELEASE</version> 
        </dependency> -->

    <dependency>
        <groupId>org.lightadmin</groupId>
        <artifactId>lightadmin</artifactId>
        <version>1.2.0.RC1</version>
    </dependency>

    <dependency>
        <groupId>org.lightadmin</groupId>
        <artifactId>light-logging-configurer</artifactId>
        <version>1.0.0.RC1</version>
    </dependency>

    <dependency>
        <groupId>org.projectlombok</groupId>
        <artifactId>lombok</artifactId>
        <scope>provided</scope>
    </dependency>

    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-core</artifactId>
        <version>4.1.4.Final</version><!--$NO-MVN-MAN-VER$ -->
    </dependency>

    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-entitymanager</artifactId>
        <version>5.2.3.Final</version><!--$NO-MVN-MAN-VER$ -->
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-thymeleaf</artifactId>
    </dependency>

    <dependency>
        <groupId>org.apache.tomcat.embed</groupId>
        <artifactId>tomcat-embed-jasper</artifactId>
        <scope>compile</scope>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
    </plugins>
</build>


AppConfig.java


@EnableJpaRepositories(basePackages= {"com.javabootstar.domain"})
@SpringBootApplication

@ComponentScan(basePackages= {"com.javabootstar.administrationConfig"})

@EntityScan(basePackages= {"com.javabootstar.domain"})

public class LightAdminExampleApplication extends SpringBootServletInitializer {

@Override
public void onStartup(ServletContext servletContext) throws ServletException {
    LightAdmin.configure(servletContext)
    .basePackage("org.lightadmin.boot.administration")
    .baseUrl("/admin")
    .security(false)
    .backToSiteUrl("http://lightadmin.org");
}

@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
    return builder.sources(LightAdminExampleApplication.class);
}

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

There are 1 answers

1
Javadroider On

I faced similar issue. I solved it by

  1. Creating new configuration class containing @EnableJpaRepositories & @EntityScan
  2. Remove @EnableJpaRepositories & @EntityScan from root application class