yan
yan copied to clipboard
yan-service如何打jar包,一直报错
yan-service如何打jar包,一直报错
使用maven进行打包
首先在yan工程下下执行install,将项目依赖安装到本地maven仓库
其次执行package进行打包
打包完成后控制台输出如下信息:
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] yan ................................................ SUCCESS [ 0.004 s]
[INFO] yan-common ......................................... SUCCESS [ 4.521 s]
[INFO] yan-plugins ........................................ SUCCESS [ 0.283 s]
[INFO] yan-dao ............................................ SUCCESS [ 1.485 s]
[INFO] yan-api ............................................ SUCCESS [ 0.462 s]
[INFO] yan-core ........................................... SUCCESS [ 0.795 s]
[INFO] yan-service ........................................ SUCCESS [ 0.478 s]
[INFO] yan-web ............................................ SUCCESS [ 7.077 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
您好,按照您的方法先install,然后package,在yan-service/target中生成yan-service-1.0-SNAPSHOT.jar 使用java -jar 运行,报没有主清单属性。 随后,我在Project Structure中Artifacts新增JAR->From modules with depenencies,并配置了主函数,如此打包后的jar,可以使用java -jar 执行成功,没有任何报错,但是就是zookeeper没有任何注册信息,即注册失败。 所以我想请教一下,如果使用java -jar 运行,且能正常注册zookeeper,这个yan-service应如何打包?多谢!
问题解决了吗?我打出来的jar包执行完报错了
问题解决了,这里配置的是通配符导致找不到这个包,这应该跟我打jar的方式有关,你们是怎么打的
我这边使用maven打包正常,请确保打包前先在工程根下执行mvn install,然后在package,若突然有问题可尝试在maven配置中build添加resource->include把指定的mapper路径下的*加入,详情可百度“maven资源文件配置”
最近较忙,没及时回复或漏回请理解!
在 2018年10月30日,17:34,hkj1994 [email protected] 写道:
问题解决了,这里配置的是通配符导致找不到这个包,这应该跟我打jar的方式有关,你们是怎么打的
— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.
感谢百忙之中抽空解答! 我看是有这个代码的,是扫描的时候,这个匹配的会每个包去扫描,扫到第一个包的时候没有找到这个 mapper 。后面指定到 com.yan.dao.mapper 打出来的包就一切正常运行了。但是这里有点疑惑的是用idea直接运行的时候就不会有这个问题,其中具体的问题我这边继续研究一下,下面贴一下我的yan-server pom.xml的配置
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>1.4</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.ManifestResourceTransformer">
<mainClass>com.yan.service.ServiceApp</mainClass>
</transformer>
<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>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
同时希望知道其中问题的能分享一下