解決maven打包缺少依賴class xxx for user defined function to_pinyin failed to load問題
1. 問題報錯
FAILED: ODPS-0130071:[1,8] Semantic analysis exception - class xxx for user defined function xxx failed to load.
Some dependencies are missing. Detail messages are: net/sourceforge/pinyin4j/format/exception/BadHanyuPinyinOutputFormatCombination
2.問題定位
(1) 打好的jar包解壓打開發(fā)現(xiàn)確實沒有發(fā)現(xiàn)依賴,定位問題到maven打jar包顯示缺少依賴
根據(jù)查找資料發(fā)現(xiàn),maven-shade-plugin提供了兩大基本功能:
- a.將依賴的jar包打包到當前jar包(常規(guī)打包是不會將所依賴jar包打進來的);
- b.對依賴的jar包進行重命名(用于類的隔離);
3.問題解決方法
在pom.xml中添加plugin java編譯插件。
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.1.0</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>xxx</mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>總結
以上為個人經(jīng)驗,希望能給大家一個參考,也希望大家多多支持腳本之家。
相關文章
數(shù)據(jù)從MySQL遷移到Oracle 需要注意什么
將數(shù)據(jù)從MySQL遷移到Oracle,大家需要注意什么?Oracle移植到mysql,又需要注意什么?如何有效解決移植過程的問題,為了數(shù)據(jù)庫的兼容性我們又該注意些什么?感興趣的小伙伴們可以參考一下2016-11-11
mysqldump命令導入導出數(shù)據(jù)庫方法與實例匯總
這篇文章主要介紹了mysqldump命令導入導出數(shù)據(jù)庫方法與實例匯總的相關資料,需要的朋友可以參考下2015-10-10

