【问题标题】:maven-assembly plugin errormaven-assembly插件错误
【发布时间】:2018-12-20 10:41:57
【问题描述】:

maven-assembly 插件导出和名为escomled-machine-learning-0.0.1-SNAPSHOT-jar-with-dependencies.jar 的可执行jar。但是当我尝试运行 jar 时,它给了我一个异常:

线程 "main" org.springframework.beans.factory.parsing.BeanDefinitionParsingException 中的异常:配置问题:找不到 XML 模式命名空间的 Spring NamespaceHandler [http://www.springframework.org/schema/context] 违规资源:类路径资源[appContext.xml]

我的pom.xml 文件:

       <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-tx</artifactId>
            <version> 3.2.4.RELEASE</version>
        </dependency>
...

            <plugin>

                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-assembly-plugin</artifactId>
                <version>3.1.0</version>

                <configuration>
                        <tarLongFileMode>posix</tarLongFileMode>

                    <descriptorRefs>
                        <descriptorRef>jar-with-dependencies</descriptorRef>
                    </descriptorRefs>
                    <archive>
                        <manifest>
                            <addClasspath>true</addClasspath>
                            <mainClass>com.escomled.machinelearning.ml.Escomled_Streams_H2O_ML</mainClass>
                        </manifest>
                    </archive>
                </configuration>
                <executions>
                    <execution>
                        <id>assemble-all</id>
                        <phase>package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

我的appContext.xml 文件:

    <beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:hz="http://www.hazelcast.com/schema/spring"
    xmlns:task="http://www.springframework.org/schema/task" xmlns:context="http://www.springframework.org/schema/context"
    xmlns:int="http://www.springframework.org/schema/integration"
    xmlns:util="http://www.springframework.org/schema/util"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.hazelcast.com/schema/spring http://www.hazelcast.com/schema/spring/hazelcast-spring-3.2.xsd 
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd 
        http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.5.xsd
        http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task.xsd ">
    <context:annotation-config />
    <context:component-scan base-package="com.escomled" />
    <context:component-scan base-package="com.escomled.*" />
    <import resource="classpath*:config/blackBoard.xml" />
    <task:annotation-driven />

    <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
        <property name="locations">
            <list>
                <value>file:///home/escomled/escomled_server/config/escomled.properties</value>
            </list>
        </property>
    </bean>

    <bean id="blackboard" class="com.escomled.blackboard.impl.BlackboardImpl">
        <property name="hazelcastInstance" ref="hazelcastClient" />
    </bean>
</beans>

注意:我尝试使用 maven-shade 插件,但没有成功。

【问题讨论】:

    标签: java maven jar maven-assembly-plugin


    【解决方案1】:

    这不是你的 maven 程序集插件的问题,而是 Spring 配置。检查您的 xml 文件并在乞讨的标记中查找名称空间包含。像这样的东西。还要检查你是否有所有的弹簧罐

    <beans xmlns="http://www.springframework.org/schema/beans"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xmlns:context="http://www.springframework.org/schema/context"
           xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
    

    【讨论】:

    • 我将使用 appContext.xml 的内容编辑任务
    • Spring Transaction 是 Spring 的唯一依赖项吗?如果是添加 Spring-context 模块。
    • 我添加了 spring-context 和 spring-core 并再次显示相同的错误
    • Exception in thread "main" org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [com.escomled.blackboard.impl.BlackboardImpl] for bean with name 'blackboard' defined in class path resource [appContext.xml]; nested exception is java.lang.ClassNotFoundException: com.escomled.blackboard.impl.BlackboardImpl 我更改了模块的版本,现在显示此错误
    • 您的 BlackboardImpl 类不在类路径中。您是否为此应用程序使用多个模块?如果是则添加依赖项,如果否则尝试更改组件扫描路径。
    猜你喜欢
    • 2013-03-14
    • 2019-01-31
    • 2010-12-29
    • 2014-05-19
    • 2016-04-17
    • 1970-01-01
    • 2016-10-08
    • 2016-11-25
    • 2016-05-18
    相关资源
    最近更新 更多