Maven挂在“类文件的搜索路径”上

问题描述

我正在将一个项目从 java 8 转移到 11,并且我只有一个类可以用来玩 JUnit 4(现在更新为 5),如果我删除这个类,mvn clean install 可以完美地工作。 测试文件对项目没有意义(对我来说),它可以被删除,但我想知道如何解决

Maven 挂起/卡住的地方

[loading modules/java.desktop/module-info.class]
[search path for source files: C:\nbpro\sindicatodesk\src\test\java,C:\nbpro\sindicatodesk\target\generated-test-sources\test-annotations]
[search path for class files: C:\jdk-11\lib\modules,C:\nbpro\sindicatodesk\target\test-classes,C:\nbpro\sindicatodesk\target\classes,C:\Users\Administrator\.m2\repository\org\glassfish\main\extras\glassfish-embedded-all\3.1.2.2\glassfish-embedded-all-3.1.2.2.jar,C:\Users\Admi.. etc etc..

测试文件

package padron;

import dao.DaoBase;
import generics.PropsUtils;
import java.io.File;
import java.io.IOException;
import java.sql.sqlException;
import java.util.Arrays;
import java.util.List;
import java.util.Properties;
import modelo.FamiliaresBaja;
import modelo.TitularesBaja;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.sindicato.Sindicato;
import org.sindicato.jpa.controller.FamiliaresJpaController;

/**
 *
 * @author FiruzzZ
 */
public class FamiliaresTest {

    @BeforeEach
    public void setUp() throws IOException,sqlException {
        Properties properties = PropsUtils.load(new File(Sindicato.propertiesFile));
        DaoBase.reconect(properties);
    }

    @Test
    public void activosTitularBaja() {
        FamiliaresJpaController dao = new FamiliaresJpaController();
        List<Object[]> ll = dao
                .findAttributes("SELECT o.id,t.codigo,o.nf FROM "
                        + dao.getAlias() + " JOIN o.titular t WHERE"
                        + " NOT exists (SELECT oo.id FROM " + FamiliaresBaja.class.getSimpleName() + " oo "
                        + " where oo.familiares = o and oo.vigente = TRUE)"
                        + " and exists (SELECT oo.id FROM " + TitularesBaja.class.getSimpleName() + " oo "
                        + " WHERE oo.titulares = t and oo.vigente = true)"
                        + " order by t.codigo,o.nf");
        ll.stream().forEach(tm -> System.out.println(Arrays.toString(tm)));
        Assertions.assertTrue(ll.isEmpty(),"Huérfanos: " + ll.size());
    }
}

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>org</groupId>
    <artifactId>sas</artifactId>
    <name>Sindicato</name>
    <description>SAS (Sistema de administración de Sindicatos)</description>
    <version>1</version>
    <packaging>jar</packaging>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.source>11</maven.compiler.source>
        <maven.compiler.target>11</maven.compiler.target>
    </properties>
    <build>
        <!-- final artifactId name maven >=3 -->
        <finalName>${project.name}</finalName>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.1</version>
                <configuration>
                    <release>11</release>
                    <compilerArgs>
                        <!-- added these lines to debug the cause of the error -->
                        <arg>-verbose</arg>
                        <arg>-Xlint:all,-options,-path</arg>
                    </compilerArgs>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.22.2</version>
                <configuration>
                    <argLine>
                        --illegal-access=warn
                    </argLine>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-failsafe-plugin</artifactId>
                <version>2.22.2</version>
                <configuration>
                    <argLine>
                        --illegal-access=warn
                    </argLine>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>properties-maven-plugin</artifactId>
                <version>1.0.0</version>
                <executions>
                    <execution>
                        <phase>initialize</phase>
                        <id>read-props</id>
                        <goals>
                            <goal>read-project-properties</goal>
                        </goals>
                        <configuration>
                            <files>
                                <file>src/main/resources/build.properties</file>
                            </files>
                        </configuration>
                    </execution>
                    <execution>
                        <phase>generate-resources</phase>
                        <id>write-props</id>
                        <goals>
                            <goal>write-project-properties</goal>
                        </goals>
                        <configuration>
                            <outputFile>src/main/resources/build.properties</outputFile>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.codehaus.gmaven</groupId>
                <artifactId>gmaven-plugin</artifactId>
                <version>1.5</version>
                <executions>
                    <execution>
                        <id>add-dynamic-properties</id>
                        <phase>initialize</phase>
                        <goals>
                            <goal>execute</goal>
                        </goals>
                        <configuration>
                            <source>
                                project.properties.buildnumber =
                                (project.properties.buildnumber.toInteger() + 1).toString();
                            </source>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <!-- debug print out,to be removed afterwards -->
<!--            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-antrun-plugin</artifactId>
                <version>1.8</version>
                <executions>
                    <execution>
                        <phase>compile</phase>
                        <goals>
                            <goal>run</goal>
                        </goals>
                        <configuration>
                            <target>
                                <echo message="buildversion=${buildnumber}" />
                            </target>
                        </configuration>
                    </execution>
                </executions>
            </plugin>-->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <executions>
                    <execution>
                        <id>copy-dependencies</id>
                        <phase>prepare-package</phase>
                        <goals>
                            <goal>copy-dependencies</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${project.build.directory}/lib</outputDirectory>
                            <includeScope>compile</includeScope>
                            <includeScope>runtime</includeScope>
                            <overWriteReleases>false</overWriteReleases>
                            <overWriteSnapshots>false</overWriteSnapshots>
                            <overWriteIfNewer>true</overWriteIfNewer>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>3.2.0</version>
                <configuration>
                    <archive>
                        <manifest>
                            <addClasspath>true</addClasspath>
                            <!--appenda el prefix al nombre de cada library que se va mencionar en Class-Path! ej: lib/unaLib.jar-->
                            <classpathPrefix>lib/</classpathPrefix>
                            <mainClass>org.sindicato.Sindicato</mainClass>
                        </manifest>
                        <manifestEntries>
                            <SplashScreen-Image>img/splash.jpg</SplashScreen-Image>
                        </manifestEntries>
                    </archive>
                </configuration>
            </plugin>
        </plugins>
    </build>
    <dependencies>
        <dependency>
            <!-- PARTE 2:
            java.lang.classFormatError: Absent Code attribute in method that is not native or abstract in class file
            https://stackoverflow.com/questions/15948598/classformaterror-absent-code-attribute-in-method-that-is-not-native-or-abstract-->
            <groupId>org.glassfish.main.extras</groupId>
            <artifactId>glassfish-embedded-all</artifactId>
            <version>3.1.2.2</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>poi</artifactId>
            <version>3.17</version>
        </dependency>
        <dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>poi-ooxml</artifactId>
            <version>3.17</version>
        </dependency>
        <dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>poi-ooxml-schemas</artifactId>
            <version>3.17</version>
        </dependency>
        <dependency>
            <groupId>org.apache.xmlbeans</groupId>
            <artifactId>xmlbeans</artifactId>
            <version>2.6.0</version>
        </dependency>
        <dependency>
            <!-- PARTE 1:
            java.lang.classFormatError: Absent Code attribute in method that is not native or abstract in class file
            https://www.mkyong.com/hibernate/java-lang-classformaterror-absent-code-attribute-in-method-that-is-not-native-or-abstract-in-class-file/-->
            <groupId>javax</groupId>
            <artifactId>javaee-api</artifactId>
            <version>6.0</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-core</artifactId>
            <version>3.6.10.Final</version> 
            <scope>compile</scope>
            <type>pom</type>
            <exclusions>
                <exclusion>
                    <groupId>org.slf4j</groupId>
                    <artifactId>slf4j-api</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-core</artifactId>
            <version>3.6.10.Final</version>
        </dependency>
        <!--        <dependency>
            <groupId>c3p0</groupId>
            <artifactId>c3p0</artifactId>
            <version>0.9.1.2</version>
        </dependency>-->
        <dependency>
            <!-- no funciona usando dependencia directa a c3p0
            java.lang.classFormatError: Absent Code attribute in method that is not native or abstract in class file 
            or 
            org.hibernate.HibernateException: Could not instantiate connection provider: org.hibernate.connection.C3P0ConnectionProvider
            -->
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-c3p0</artifactId>
            <version>3.6.10.Final</version>
            <exclusions>
                <exclusion>
                    <groupId>org.slf4j</groupId>
                    <artifactId>slf4j-api</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <!-- para los lazy load,similar al weaving the eclipselink -->
            <groupId>org.javassist</groupId>
            <artifactId>javassist</artifactId>
            <version>3.28.0-GA</version>
        </dependency>
        <dependency>
            <groupId>org.postgresql</groupId>
            <artifactId>postgresql</artifactId>
            <version>42.2.22</version>
        </dependency>
        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-core</artifactId>
            <version>2.4.1</version>
        </dependency>
        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-api</artifactId>
            <version>2.4.1</version>
            <type>jar</type>
        </dependency>
        <dependency>
            <!--bridge para routear los logging de 1.x al 2.x-->
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-jcl</artifactId>
            <version>2.4.1</version>
        </dependency>
        <dependency>
            <!--bridge para routear los SLF4J a Log4j2-->
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-slf4j-impl</artifactId>
            <version>2.4.1</version>
        </dependency>
        <dependency>
            <!--bridge para routear los JUL a Log4j2-->
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-jul</artifactId>
            <version>2.4.1</version>
        </dependency>
        <dependency>
            <groupId>com</groupId>
            <artifactId>utilitiez</artifactId>
            <version>1</version>
        </dependency>
        <dependency>
            <groupId>com.toedter</groupId>
            <artifactId>jcalendar</artifactId>
            <version>1.4</version>
        </dependency>
        <dependency>
            <groupId>net.sf.jasperreports</groupId>
            <artifactId>jasperreports</artifactId>
            <!-- downgraded a 6.4.1 por culpa de DynamicJasper -->
            <version>6.17.0</version>
        </dependency>
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
            <version>3.4</version>
        </dependency>
        <dependency>
            <groupId>org.swinglabs.swingx</groupId>
            <artifactId>swingx-all</artifactId>
            <version>1.6.5</version>
        </dependency>
        <dependency>
            <groupId>com.miglayout</groupId>
            <artifactId>miglayout-swing</artifactId>
            <version>5.3</version>
        </dependency>
        <dependency>
            <groupId>javax.activation</groupId>
            <artifactId>activation</artifactId>
            <version>1.1.1</version>
        </dependency>
        <dependency>
            <groupId>org.dom4j</groupId>
            <artifactId>dom4j</artifactId>
            <version>2.1.3</version>
        </dependency>
        <dependency>
            <groupId>ar.com.fdvs</groupId>
            <artifactId>DynamicJasper</artifactId>
            <version>5.3.2</version>
            <exclusions>
                <exclusion>
                    <groupId>stax</groupId>
                    <artifactId>stax-api</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.apache.lucene</groupId>
                    <artifactId>lucene-analyzers-common</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.apache.lucene</groupId>
                    <artifactId>lucene-core</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.apache.lucene</groupId>
                    <artifactId>lucene-queries</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.apache.lucene</groupId>
                    <artifactId>lucene-queryparser</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.olap4j</groupId>
                    <artifactId>olap4j</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.bouncycastle</groupId>
                    <artifactId>bctsp-jdk14</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>bouncycastle</groupId>
                    <artifactId>bcmail-jdk14</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>bouncycastle</groupId>
                    <artifactId>bcprov-jdk14</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.codehaus.castor</groupId>
                    <artifactId>castor</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.codehaus.castor</groupId>
                    <artifactId>castor-core</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>com.fasterxml.jackson.core</groupId>
                    <artifactId>jackson-annotations</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>com.fasterxml.jackson.core</groupId>
                    <artifactId>jackson-core</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>com.fasterxml.jackson.core</groupId>
                    <artifactId>jackson-databind</artifactId>
                </exclusion>
                <!-- ecj es necesario para los JRXML que compila dynamicJasper -->
                <!-- <exclusion>
                    <groupId>org.eclipse.jdt.core.compiler</groupId>
                    <artifactId>ecj</artifactId>
                </exclusion>-->
            </exclusions>
        </dependency>
        <dependency>
            <groupId>eclipse</groupId>
            <!-- necesario para los JRXML que compila dynamicJasper -->
            <artifactId>jdtcore</artifactId>
            <version>3.1.0</version>
        </dependency>
        <dependency>
            <groupId>net.sf.supercsv</groupId>
            <artifactId>super-csv</artifactId>
            <version>2.4.0</version>
        </dependency>
        <dependency>
            <groupId>commons-discovery</groupId>
            <artifactId>commons-discovery</artifactId>
            <version>0.5</version>
        </dependency>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-engine</artifactId>
            <version>5.7.2</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.hotswapagent</groupId>
            <artifactId>hotswap-agent</artifactId>
            <version>1.3.0</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.google.code.gson</groupId>
            <artifactId>gson</artifactId>
            <version>2.2.3</version>
            <type>jar</type>
        </dependency>
        <dependency>
            <groupId>com.github.albfernandez</groupId>
            <artifactId>javadbf</artifactId>
            <version>1.11.2</version>
        </dependency>
        <dependency>
            <groupId>javax.mail</groupId>
            <artifactId>mail</artifactId>
            <version>1.4.1</version>
            <type>jar</type>
        </dependency>
    </dependencies>
 
</project>

我找不到与此问题相关的任何内容,我在 Java 11 的冒险中遗漏了什么? 在 Windows 10 上使用 OpenJDK 11

解决方法

将 Hibernate 依赖项 3.6 更新到 5.5.3 解决了问题