我有一个Maven应用,我想从中制作一个可执行文件.jar
。我尝试使用maven-jar-plugin
,但运行由maven-jar-plugin制作的.jar
文件时,出现错误:Can't find main manifest
。我也尝试使用maven-assembly-plugin
,但它给出了一个错误:
线程“主”中的异常org.springframework.beans.factory.parsing.BeanDefinitionParsingException:配置问题:无法找到XML模式名称空间[http://www.springframework.org/schema/context]的Spring NamespaceHandler 令人反感的资源:类路径资源[appContext.xml]
我尝试使用maven-shade-plugin
,但与NamespaceHandler
给出了相同的错误。我四处张望,似乎找不到解决问题的方法。
我的应用程序还使用另一个应用程序中的.jar
,该应用程序已添加到类路径中。我也尝试将它们放在同一目录中,但这也不起作用。
我的pom.xml
文件的一部分:
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
<version>${org.springframework-version}</version>
</dependency>
<!-- spring -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${org.springframework-version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${org.springframework-version}</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
文件:
<?xml version="1.0" encoding="UTF-8"?>
<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>
我尝试了很多事情,但都无济于事,.jar
无法正常工作,所以有人可以从一开始就告诉我怎么做以及我在做什么错吗?
(如果您需要其他信息,我会编辑我的问题,只需发表评论即可)
答案 0 :(得分:0)
在使用maven-assembly-plugin时,您是否尝试运行此命令:
mvn assembly:assembly -DdescriptorId=jar-with-dependencies package