当前位置: 首页 > 知识库问答 >
问题:

java.lang.NoSuchFieldError: parallelCapableClassLoaderAvailable

刘承运
2023-03-14

嗨,又是我,我现在在启动我的应用程序时出现了这个错误:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaAutoConfiguration.class]: Invocation of init method failed; nested exception is java.lang.NoSuchFieldError: parallelCapableClassLoaderAvailable
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1717) ~[spring-beans-5.0.0.RC2.jar:5.0.0.RC2]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:581) ~[spring-beans-5.0.0.RC2.jar:5.0.0.RC2]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:498) ~[spring-beans-5.0.0.RC2.jar:5.0.0.RC2]
        at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:305) ~[spring-beans-5.0.0.RC2.jar:5.0.0.RC2]
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:233) ~[spring-beans-5.0.0.RC2.jar:5.0.0.RC2]
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:303) ~[spring-beans-5.0.0.RC2.jar:5.0.0.RC2]
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193) ~[spring-beans-5.0.0.RC2.jar:5.0.0.RC2]
        at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1078) ~[spring-context-4.3.9.RELEASE.jar:4.3.9.RELEASE]
        at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:857) ~[spring-context-4.3.9.RELEASE.jar:4.3.9.RELEASE]
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:543) ~[spring-context-4.3.9.RELEASE.jar:4.3.9.RELEASE]
        at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:693) [spring-boot-1.5.4.RELEASE.jar:1.5.4.RELEASE]
        at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:360) [spring-boot-1.5.4.RELEASE.jar:1.5.4.RELEASE]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:303) [spring-boot-1.5.4.RELEASE.jar:1.5.4.RELEASE]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1118) [spring-boot-1.5.4.RELEASE.jar:1.5.4.RELEASE]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1107) [spring-boot-1.5.4.RELEASE.jar:1.5.4.RELEASE]
        at com.o2xp.ats.accountManager.test.App.main(App.java:42) [classes/:na]
    Caused by: java.lang.NoSuchFieldError: parallelCapableClassLoaderAvailable
        at org.springframework.instrument.classloading.SimpleThrowawayClassLoader.<clinit>(SimpleThrowawayClassLoader.java:34) ~[spring-context-4.3.9.RELEASE.jar:4.3.9.RELEASE]
        at org.springframework.orm.jpa.persistenceunit.SpringPersistenceUnitInfo.getNewTempClassLoader(SpringPersistenceUnitInfo.java:90) ~[spring-orm-4.3.9.RELEASE.jar:4.3.9.RELEASE]
        at org.hibernate.jpa.boot.internal.PersistenceUnitInfoDescriptor.getTempClassLoader(PersistenceUnitInfoDescriptor.java:78) ~[hibernate-entitymanager-5.0.12.Final.jar:5.0.12.Final]
        at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.populate(EntityManagerFactoryBuilderImpl.java:765) ~[hibernate-entitymanager-5.0.12.Final.jar:5.0.12.Final]
        at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.<init>(EntityManagerFactoryBuilderImpl.java:186) ~[hibernate-entitymanager-5.0.12.Final.jar:5.0.12.Final]
        at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.<init>(EntityManagerFactoryBuilderImpl.java:149) ~[hibernate-entitymanager-5.0.12.Final.jar:5.0.12.Final]
        at org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityManagerFactory(SpringHibernateJpaPersistenceProvider.java:54) ~[spring-orm-4.3.9.RELEASE.jar:4.3.9.RELEASE]
        at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:353) ~[spring-orm-4.3.9.RELEASE.jar:4.3.9.RELEASE]
        at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.buildNativeEntityManagerFactory(AbstractEntityManagerFactoryBean.java:370) ~[spring-orm-4.3.9.RELEASE.jar:4.3.9.RELEASE]
        at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:359) ~[spring-orm-4.3.9.RELEASE.jar:4.3.9.RELEASE]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1774) ~[spring-beans-5.0.0.RC2.jar:5.0.0.RC2]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1713) ~[spring-beans-5.0.0.RC2.jar:5.0.0.RC2]
        ... 15 common frames omitted

我找不到原因,我确切地说这是一个带有模块的maven项目,所以我将所有依赖项放在父模块pom文件中:

<?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>
   <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>   
                </configuration>
            </plugin>
           <plugin>
              <groupId>org.springframework.boot</groupId>  
              <artifactId>spring-boot-maven-plugin</artifactId>
           </plugin>
       </plugins>
   </build>
  <packaging>pom</packaging>
  <groupId>com.o2xp</groupId>
  <artifactId>ats-impl</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <name>ats-impl</name>
  <url>http://maven.apache.org</url>
  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>
  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.12</version>
      <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.mockito</groupId>
        <artifactId>mockito-all</artifactId>
        <version>1.9.5</version>
        <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-context-support</artifactId>
      <version>4.3.9.RELEASE</version>
    </dependency>
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-web</artifactId>
      <version>4.3.9.RELEASE</version>
    </dependency>
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-context</artifactId>
      <version>4.3.9.RELEASE</version>
    </dependency>
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-test</artifactId>
      <version>LATEST</version>
      <scope>4.3.9.RELEASE</scope>
    </dependency>
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-data-jpa</artifactId>
      <version>1.5.4.RELEASE</version>
    </dependency>
    <dependency>
      <groupId>com.h2database</groupId>
      <artifactId>h2</artifactId>
      <version>LATEST</version>
    </dependency>
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-test</artifactId>
      <version>1.5.4.RELEASE</version>
      <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot</artifactId>
        <version>1.5.4.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.mapstruct</groupId>
        <artifactId>mapstruct-processor</artifactId>
        <version>1.1.0.Final</version>
    </dependency>
    <dependency>
        <groupId>io.github.jhipster</groupId>
        <artifactId>jhipster</artifactId>
        <version>1.1.6</version>
    </dependency>
  </dependencies>
   <repositories>
        <repository>
            <id>spring-releases</id>
            <name>Spring Releases</name>
            <url>https://repo.spring.io/libs-release</url>
        </repository>
        <repository>
            <id>org.jboss.repository.releases</id>
            <name>JBoss Maven Release Repository</name>
            <url>https://repository.jboss.org/nexus/content/repositories/releases</url>
        </repository>
        <repository>
            <id>spring-milestone</id>
            <name>Spring Milestone Repository</name>
            <url>https://repo.spring.io/milestone</url>
        </repository>
    </repositories>

    <pluginRepositories>
        <pluginRepository>
            <id>spring-releases</id>
            <name>Spring Releases</name>
            <url>https://repo.spring.io/libs-release</url>
        </pluginRepository>
    </pluginRepositories>
  <modules>
    <module>ats-application-context</module>
    <module>ats-notice-manager</module>
    <module>ats-common</module>
    <module>ats-accountManager</module>
  </modules>
</project>

这是我的应用程序类:

package com.o2xp.ats.accountManager.test;

import java.util.ArrayList;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.domain.EntityScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;

import com.o2xp.ats.accountManager.services.ti.ApplicantService;
import com.o2xp.ats.accountManager.to.ApplicantTO;
import com.o2xp.ats.accountManager.to.JobExperienceTO;
import com.o2xp.ats.api.common.DomainIdentifier;
import com.o2xp.ats.common.services.ti.CategoryService;
import com.o2xp.ats.common.services.ti.DomainService;
import com.o2xp.ats.common.services.ti.LocationService;
import com.o2xp.ats.common.services.ti.SkillService;
import com.o2xp.ats.common.to.CategoryTO;
import com.o2xp.ats.common.to.DomainTO;
import com.o2xp.ats.common.to.LocationTO;
import com.o2xp.ats.common.to.SkillTO;

/**
 * Hello world!
 *
 */
@SpringBootApplication
@ComponentScan({ "com.o2xp.ats.common.domain", "com.o2xp.ats.common.services", "com.o2xp.ats.common.mapper",
        "com.o2xp.ats.accountManager.services", "com.o2xp.ats.accountManager.mapper",
        "com.o2xp.ats.accountManager.domain" })
@EnableJpaRepositories({ "com.o2xp.ats.common.repository", "com.o2xp.ats.accountManager.repository" })
@EntityScan({ "com.o2xp.ats.common.domain", "com.o2xp.ats.accountManager.domain" })
public class App {
    private static final Logger log = LoggerFactory.getLogger(App.class);

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

    @Bean
    public CommandLineRunner demo(CategoryService categoryService, SkillService skillService,
            LocationService locationService, ApplicantService applicantService, DomainService domainService) {
        return (args) -> {

            DomainIdentifier dI1 = new DomainIdentifier((long) 1, "DevOps");
            DomainIdentifier dI2 = new DomainIdentifier((long) 2, "RH");

            DomainTO d1 = (DomainTO) domainService.save(new DomainTO(dI1));
            DomainTO d2 = (DomainTO) domainService.save(new DomainTO(dI2));

            ApplicantTO a1 = (ApplicantTO) applicantService.save(new ApplicantTO((long) 1, "Nahmias", "Vincent",
                    "sdfgs@gmail.com", "040511kev", new ArrayList<LocationTO>(), false, false, false, false, false, 0,
                    d2, new ArrayList<CategoryTO>(), new ArrayList<SkillTO>(), new ArrayList<JobExperienceTO>()));
            a1 = (ApplicantTO) applicantService.addDomain("DevOps", a1.getId());

            // System.out.println(a1.getDomain());
            System.out.println(applicantService.getAllApplicants());

        };
    }
}

我觉得问题出在pom,但是找不到在哪里。

共有1个答案

丌官积厚
2023-03-14

尝试升级springboot版本并添加此依赖项

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-aop</artifactId>
        <version>${spring.version}</version>
    </dependency>
 类似资料:

相关问答

相关文章

相关阅读