2

同事们,我使用mvn clean package并接收下一个堆栈跟踪构建了我的项目:

10:12:06.713 INFO  [main] org.hibernate.Version - HHH000412: Hibernate Core {[WORKING]}
10:12:06.715 INFO  [main] org.hibernate.cfg.Environment - HHH000206: hibernate.properties not found
10:12:06.739 INFO  [main] o.h.annotations.common.Version - HCANN000001: Hibernate Commons Annotations {5.0.1.Final}
10:12:08.244 WARN  [main] o.s.c.a.AnnotationConfigApplicationContext - Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'emFactorymort' defined in class path resource [ru/pivotal/olme/cap_qort_config/olmemortConfig.class]: Invocation of init method failed; nested exception is java.lang.TypeNotPresentException: Type org.threeten.bp.LocalDateTime not present
Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'emFactorymort' defined in class path resource [ru/pivotal/olme/cap_qort_config/olmemortConfig.class]: Invocation of init method failed; nested exception is java.lang.TypeNotPresentException: Type org.threeten.bp.LocalDateTime not present
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1589)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:554)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483)
        at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
        at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1081)
        at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:856)
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:542)
        at org.springframework.context.annotation.AnnotationConfigApplicationContext.<init>(AnnotationConfigApplicationContext.java:84)
        at com.pivotal.olme.OlmeFtp.main(OlmeFtp.java:21)
Caused by: java.lang.TypeNotPresentException: Type org.threeten.bp.LocalDateTime not present
        at sun.reflect.generics.factory.CoreReflectionFactory.makeNamedType(Unknown Source)
        at sun.reflect.generics.visitor.Reifier.visitClassTypeSignature(Unknown Source)
        at sun.reflect.generics.tree.ClassTypeSignature.accept(Unknown Source)
        at sun.reflect.generics.visitor.Reifier.reifyTypeArguments(Unknown Source)
        at sun.reflect.generics.visitor.Reifier.visitClassTypeSignature(Unknown Source)
        at sun.reflect.generics.tree.ClassTypeSignature.accept(Unknown Source)
        at sun.reflect.generics.repository.ClassRepository.getSuperInterfaces(Unknown Source)
        at java.lang.Class.getGenericInterfaces(Unknown Source)
        at org.hibernate.cfg.AttributeConverterDefinition.extractAttributeConverterParameterizedType(AttributeConverterDefinition.java:157)
        at org.hibernate.cfg.AttributeConverterDefinition.<init>(AttributeConverterDefinition.java:114)
        at org.hibernate.cfg.AttributeConverterDefinition.from(AttributeConverterDefinition.java:93)
        at org.hibernate.cfg.AttributeConverterDefinition.from(AttributeConverterDefinition.java:73)
        at org.hibernate.boot.model.process.internal.ScanningCoordinator.applyScanResultsToManagedResources(ScanningCoordinator.java:234)
        at org.hibernate.boot.model.process.internal.ScanningCoordinator.coordinateScan(ScanningCoordinator.java:81)
        at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.prepare(MetadataBuildingProcess.java:98)
        at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.<init>(EntityManagerFactoryBuilderImpl.java:228)
        at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.<init>(EntityManagerFactoryBuilderImpl.java:163)
        at org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityManagerFactory(SpringHibernateJpaPersistenceProvider.java:54)
        at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:353)
        at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.buildNativeEntityManagerFactory(AbstractEntityManagerFactoryBean.java:373)
        at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:362)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1648)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1585)
        ... 11 more
Caused by: java.lang.ClassNotFoundException: org.threeten.bp.LocalDateTime
        at java.net.URLClassLoader.findClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Unknown Source)
        ... 34 more

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>


    <parent>
        <groupId>com.pivotal.olme</groupId>
        <artifactId>parent</artifactId>
        <version>1.2-SNAPSHOT</version>
    </parent>


    <groupId>com.pivotal.olme</groupId>
    <artifactId>olme-ftp</artifactId>
    <version>1.3-SNAPSHOT</version>


    <name>olme :: FTP</name>
    <description>olme-FTP integration</description>


    <dependencies>

      <dependency>
             <groupId>org.springframework</groupId>
             <artifactId>spring-context</artifactId>
            <version>${spring.version}</version>
         </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-tx</artifactId>
            <version>${spring.version}</version>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-test</artifactId>
            <scope>test</scope>
            <version>${spring.version}</version>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-orm</artifactId>
            <version>${spring.version}</version>
        </dependency>

        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-core</artifactId>
            <version>5.2.6.Final</version>
        </dependency>


        <!-- https://mvnrepository.com/artifact/org.springframework.data/spring-data-jpa -->
        <dependency>
            <groupId>org.springframework.data</groupId>
            <artifactId>spring-data-jpa</artifactId>
            <version>1.11.1.RELEASE</version>
        </dependency>

        <!--Logging-->
        <dependency>
            <groupId>ch.qos.logback</groupId>
            <artifactId>logback-classic</artifactId>
            <version>1.1.9</version>
        </dependency>

        <dependency>
            <groupId>me.moocar</groupId>
            <artifactId>logback-gelf</artifactId>
        </dependency>

        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>jul-to-slf4j</artifactId>
            <version>1.7.22</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>jcl-over-slf4j</artifactId>
            <version>1.7.22</version>
        </dependency>


        <dependency>
            <groupId>commons-io</groupId>
            <artifactId>commons-io</artifactId>
        </dependency>


        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
        </dependency>

        <dependency>
            <groupId>joda-time</groupId>
            <artifactId>joda-time</artifactId>
            <version>2.8.2</version>
        </dependency>


        <!-- https://mvnrepository.com/artifact/commons-net/commons-net -->
        <dependency>
            <groupId>commons-net</groupId>
            <artifactId>commons-net</artifactId>
            <version>3.3</version>
        </dependency>


        <!-- Needed for com/jcraft/jsch/Logger - SFTP -->
            <dependency>
                <groupId>com.jcraft</groupId>
                <artifactId>jsch</artifactId>
                <version>0.1.42</version>
            </dependency>

            <!-- JUnit for testing -->
            <dependency>
                <groupId>junit</groupId>
                <artifactId>junit</artifactId>
                <version>4.12</version>
            </dependency>



        <dependency>
            <groupId>pl.touk</groupId>
            <artifactId>tsc-reload</artifactId>
            <version>0.3.0</version>
        </dependency>


        <dependency>
            <groupId>com.typesafe</groupId>
            <artifactId>config</artifactId>
            <version>1.3.0</version>

        </dependency>

        <!-- https://mvnrepository.com/artifact/commons-collections/commons-collections -->


        <dependency>
            <groupId>commons-collections</groupId>
            <artifactId>commons-collections</artifactId>
            <version>3.2.2</version>
        </dependency>


        <!-- https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-shade-plugin -->
        <dependency>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-shade-plugin</artifactId>
            <version>2.4.3</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context-support</artifactId>
            <version>4.2.4.RELEASE</version>
        </dependency>

        <dependency>
            <groupId>org.thymeleaf</groupId>
            <artifactId>thymeleaf</artifactId>
            <version>3.0.2.RELEASE</version>
        </dependency>

        <dependency>
            <groupId>org.thymeleaf</groupId>
            <artifactId>thymeleaf-spring4</artifactId>
            <version>3.0.2.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>javax.mail</groupId>
            <artifactId>mail</artifactId>
            <version>1.4.7</version>
        </dependency>
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-dbcp2</artifactId>
            <version>2.1.1</version>

            <exclusions>
                <exclusion>
                    <groupId>commons-logging</groupId>
                    <artifactId>commons-logging</artifactId>
                </exclusion>
            </exclusions>

        </dependency>

        <dependency>
            <groupId>com.microsoft.sqlserver</groupId>
            <artifactId>sqljdbc4</artifactId>
            <version>4.2</version>
        </dependency>


        <dependency>
            <groupId>org.fluttercode.datafactory</groupId>
            <artifactId>datafactory</artifactId>
            <version>0.8</version>
        </dependency>

        <dependency>
            <groupId>com.pivotal.qort</groupId>
            <artifactId>utils</artifactId>
            <version>1.9.3-SNAPSHOT</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/commons-beanutils/commons-beanutils -->
        <dependency>
            <groupId>commons-beanutils</groupId>
            <artifactId>commons-beanutils</artifactId>
            <version>1.9.3</version>
        </dependency>
        <dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>poi</artifactId>
            <version>3.15</version>
        </dependency>


    </dependencies>





    <build>
        <finalName>olme-ftp-1.2-SNAPSHOT</finalName>
        <plugins>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <version>2.4.3</version>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                        <configuration>
                            <filters>
                                <filter>
                                    <artifact>*:*</artifact>
                                    <excludes>
                                        <exclude>META-INF/*.SF</exclude>
                                        <exclude>META-INF/*.DSA</exclude>
                                        <exclude>META-INF/*.RSA</exclude>
                                    </excludes>
                                </filter>
                            </filters>

                            <transformers>
                                <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
                                    <resource>META-INF/spring.handlers</resource>
                                </transformer>
                                <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
                                    <resource>META-INF/spring.schemas</resource>
                                </transformer>
                                <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                                    <mainClass>com.pivotal.olme.olmeFtp</mainClass>
                                </transformer>
                            </transformers>
                        </configuration>
                    </execution>
                </executions>
            </plugin>


            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.19.1</version>
                <configuration>
                    <argLine>-Denv=dev</argLine>
                </configuration>
            </plugin>

        </plugins>
    </build>


</project>

mvn dependency:tree返回:

[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) @ olme-ftp ---
[INFO] com.pivotal.olme:olme-ftp:jar:1.3-SNAPSHOT
[INFO] +- org.springframework:spring-context:jar:4.3.5.RELEASE:compile
[INFO] |  +- org.springframework:spring-aop:jar:4.3.5.RELEASE:compile
[INFO] |  +- org.springframework:spring-beans:jar:4.3.5.RELEASE:compile
[INFO] |  +- org.springframework:spring-core:jar:4.3.5.RELEASE:compile
[INFO] |  \- org.springframework:spring-expression:jar:4.3.5.RELEASE:compile
[INFO] +- org.springframework:spring-tx:jar:4.3.5.RELEASE:compile
[INFO] +- org.springframework:spring-test:jar:4.3.5.RELEASE:test
[INFO] +- org.springframework:spring-orm:jar:4.3.5.RELEASE:compile
[INFO] |  \- org.springframework:spring-jdbc:jar:4.3.5.RELEASE:compile
[INFO] +- org.hibernate:hibernate-core:jar:5.2.6.Final:compile
[INFO] |  +- org.jboss.logging:jboss-logging:jar:3.3.0.Final:compile
[INFO] |  +- org.hibernate.javax.persistence:hibernate-jpa-2.1-api:jar:1.0.0.Final:compile
[INFO] |  +- org.javassist:javassist:jar:3.20.0-GA:compile
[INFO] |  +- antlr:antlr:jar:2.7.7:compile
[INFO] |  +- org.apache.geronimo.specs:geronimo-jta_1.1_spec:jar:1.1.1:compile
[INFO] |  +- org.jboss:jandex:jar:2.0.3.Final:compile
[INFO] |  +- com.fasterxml:classmate:jar:1.3.0:compile
[INFO] |  +- dom4j:dom4j:jar:1.6.1:compile
[INFO] |  +- org.hibernate.common:hibernate-commons-annotations:jar:5.0.1.Final:compile
[INFO] |  \- javax.enterprise:cdi-api:jar:1.1:compile
[INFO] |     +- javax.el:el-api:jar:2.2:compile
[INFO] |     +- org.jboss.spec.javax.interceptor:jboss-interceptors-api_1.1_spec:jar:1.0.0.Beta1:compile
[INFO] |     +- javax.annotation:jsr250-api:jar:1.0:compile
[INFO] |     \- javax.inject:javax.inject:jar:1:compile
[INFO] +- org.springframework.data:spring-data-jpa:jar:1.11.1.RELEASE:compile
[INFO] |  +- org.springframework.data:spring-data-commons:jar:1.13.1.RELEASE:compile
[INFO] |  +- org.aspectj:aspectjrt:jar:1.8.10:compile
[INFO] |  \- org.slf4j:slf4j-api:jar:1.7.24:compile
[INFO] +- ch.qos.logback:logback-classic:jar:1.1.9:compile
[INFO] |  \- ch.qos.logback:logback-core:jar:1.1.9:compile
[INFO] +- me.moocar:logback-gelf:jar:0.3:compile
[INFO] |  +- com.google.code.gson:gson:jar:2.3.1:compile
[INFO] |  \- me.moocar:socket-encoder-appender:jar:0.1beta1:compile
[INFO] +- org.slf4j:jul-to-slf4j:jar:1.7.22:compile
[INFO] +- org.slf4j:jcl-over-slf4j:jar:1.7.22:compile
[INFO] +- commons-io:commons-io:jar:2.2:compile
[INFO] +- org.apache.commons:commons-lang3:jar:3.5:compile
[INFO] +- joda-time:joda-time:jar:2.8.2:compile
[INFO] +- commons-net:commons-net:jar:3.3:compile
[INFO] +- com.jcraft:jsch:jar:0.1.42:compile
[INFO] +- junit:junit:jar:4.12:test
[INFO] |  \- org.hamcrest:hamcrest-core:jar:1.3:test
[INFO] +- pl.touk:tsc-reload:jar:0.3.0:compile
[INFO] |  \- com.javaslang:javaslang:jar:2.0.0-RC3:compile
[INFO] +- com.typesafe:config:jar:1.3.0:compile
[INFO] +- commons-collections:commons-collections:jar:3.2.2:compile
[INFO] +- org.apache.maven.plugins:maven-shade-plugin:jar:2.4.3:compile
[INFO] |  +- org.apache.maven:maven-plugin-api:jar:3.0:compile
[INFO] |  |  \- org.sonatype.sisu:sisu-inject-plexus:jar:1.4.2:compile
[INFO] |  |     \- org.sonatype.sisu:sisu-inject-bean:jar:1.4.2:compile
[INFO] |  |        \- org.sonatype.sisu:sisu-guice:jar:noaop:2.1.7:compile
[INFO] |  +- org.apache.maven:maven-model:jar:3.0:compile
[INFO] |  +- org.apache.maven:maven-core:jar:3.0:compile
[INFO] |  |  +- org.apache.maven:maven-settings:jar:3.0:compile
[INFO] |  |  +- org.apache.maven:maven-settings-builder:jar:3.0:compile
[INFO] |  |  +- org.apache.maven:maven-repository-metadata:jar:3.0:compile
[INFO] |  |  +- org.apache.maven:maven-model-builder:jar:3.0:compile
[INFO] |  |  +- org.apache.maven:maven-aether-provider:jar:3.0:runtime
[INFO] |  |  +- org.sonatype.aether:aether-impl:jar:1.7:compile
[INFO] |  |  |  \- org.sonatype.aether:aether-spi:jar:1.7:compile
[INFO] |  |  +- org.sonatype.aether:aether-api:jar:1.7:compile
[INFO] |  |  +- org.sonatype.aether:aether-util:jar:1.7:compile
[INFO] |  |  +- org.codehaus.plexus:plexus-interpolation:jar:1.14:compile
[INFO] |  |  +- org.codehaus.plexus:plexus-classworlds:jar:2.2.3:compile
[INFO] |  |  +- org.codehaus.plexus:plexus-component-annotations:jar:1.5.5:compile
[INFO] |  |  \- org.sonatype.plexus:plexus-sec-dispatcher:jar:1.3:compile
[INFO] |  |     \- org.sonatype.plexus:plexus-cipher:jar:1.4:compile
[INFO] |  +- org.apache.maven:maven-compat:jar:3.0:compile
[INFO] |  |  \- org.apache.maven.wagon:wagon-provider-api:jar:1.0-beta-6:compile
[INFO] |  +- org.apache.maven:maven-artifact:jar:3.0:compile
[INFO] |  +- org.codehaus.plexus:plexus-utils:jar:3.0.22:compile
[INFO] |  +- org.ow2.asm:asm:jar:5.0.2:compile
[INFO] |  +- org.ow2.asm:asm-commons:jar:5.0.2:compile
[INFO] |  |  \- org.ow2.asm:asm-tree:jar:5.0.2:compile
[INFO] |  +- org.jdom:jdom:jar:1.1:compile
[INFO] |  +- org.apache.maven.shared:maven-dependency-tree:jar:2.2:compile
[INFO] |  |  \- org.eclipse.aether:aether-util:jar:0.9.0.M2:compile
[INFO] |  +- org.vafer:jdependency:jar:1.1:compile
[INFO] |  |  +- org.ow2.asm:asm-analysis:jar:5.0.4:compile
[INFO] |  |  \- org.ow2.asm:asm-util:jar:5.0.4:compile
[INFO] |  \- com.google.guava:guava:jar:11.0.2:compile
[INFO] |     \- com.google.code.findbugs:jsr305:jar:1.3.9:compile
[INFO] +- org.springframework:spring-context-support:jar:4.2.4.RELEASE:compile
[INFO] +- org.thymeleaf:thymeleaf:jar:3.0.2.RELEASE:compile
[INFO] |  +- ognl:ognl:jar:3.1.10:compile
[INFO] |  +- org.attoparser:attoparser:jar:2.0.1.RELEASE:compile
[INFO] |  \- org.unbescape:unbescape:jar:1.1.4.RELEASE:compile
[INFO] +- org.thymeleaf:thymeleaf-spring4:jar:3.0.2.RELEASE:compile
[INFO] +- javax.mail:mail:jar:1.4.7:compile
[INFO] |  \- javax.activation:activation:jar:1.1:compile
[INFO] +- org.apache.commons:commons-dbcp2:jar:2.1.1:compile
[INFO] |  \- org.apache.commons:commons-pool2:jar:2.4.2:compile
[INFO] +- com.microsoft.sqlserver:sqljdbc4:jar:4.2:compile
[INFO] +- org.fluttercode.datafactory:datafactory:jar:0.8:compile
[INFO] +- com.pivotal.qort:utils:jar:1.9.3-SNAPSHOT:compile
[INFO] |  \- com.sun.mail:javax.mail:jar:1.5.5:compile
[INFO] +- commons-beanutils:commons-beanutils:jar:1.9.3:compile
[INFO] |  \- commons-logging:commons-logging:jar:1.2:compile
[INFO] \- org.apache.poi:poi:jar:3.15:compile
[INFO]    +- commons-codec:commons-codec:jar:1.10:compile
[INFO]    \- org.apache.commons:commons-collections4:jar:4.1:compile

在我的情况下如何修复 ClassNotFoundException?

做了什么:

  • mvn clean -U添加

  • <maven.compiler.source>1.8</maven.compiler.source>和“1.8 intoof parentpom”。

  • 所有测试都在 IDE (IDE) 中无一例外地通过
4

2 回答 2

1

检查您的 EntityManager 创建配置,您的实体包(模型包)扫描配置错误/丢失的地方。

于 2020-04-23T12:51:46.830 回答
1

如错误 ClassNotFoundException所述,您必须将未找到的依赖项包含到您的 POM 中。这应该可以修复错误。

于 2017-04-06T08:21:15.187 回答