解決maven打包缺少依賴class xxx for user defined function to_pinyin failed to load問題
1. 問題報(bào)錯(cuò)
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)確實(shí)沒有發(fā)現(xiàn)依賴,定位問題到maven打jar包顯示缺少依賴
根據(jù)查找資料發(fā)現(xiàn),maven-shade-plugin提供了兩大基本功能:
- a.將依賴的jar包打包到當(dāng)前jar包(常規(guī)打包是不會(huì)將所依賴jar包打進(jìn)來的);
- b.對(duì)依賴的jar包進(jìn)行重命名(用于類的隔離);
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>
<!-- 這里必須要填下面這段,否則報(bào)錯(cuò) -->
<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">
<!-- 下面這里要填要運(yùn)行的類,否則會(huì)報(bào)錯(cuò) -->
<mainClass>xxx</mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>總結(jié)
以上為個(gè)人經(jīng)驗(yàn),希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。
相關(guān)文章
數(shù)據(jù)從MySQL遷移到Oracle 需要注意什么
將數(shù)據(jù)從MySQL遷移到Oracle,大家需要注意什么?Oracle移植到mysql,又需要注意什么?如何有效解決移植過程的問題,為了數(shù)據(jù)庫的兼容性我們又該注意些什么?感興趣的小伙伴們可以參考一下2016-11-11
mysqldump命令導(dǎo)入導(dǎo)出數(shù)據(jù)庫方法與實(shí)例匯總
這篇文章主要介紹了mysqldump命令導(dǎo)入導(dǎo)出數(shù)據(jù)庫方法與實(shí)例匯總的相關(guān)資料,需要的朋友可以參考下2015-10-10
MySQL 定時(shí)新增分區(qū)的實(shí)現(xiàn)示例
本文主要介紹了通過存儲(chǔ)過程和定時(shí)任務(wù)實(shí)現(xiàn)MySQL分區(qū)的自動(dòng)創(chuàng)建,解決大數(shù)據(jù)量下手動(dòng)維護(hù)的繁瑣問題,具有一定的參考價(jià)值,感興趣的可以了解一下2025-07-07
Mysql8.0輕松實(shí)現(xiàn)主從復(fù)制
這篇文章主要介紹了Mysql8.0輕松實(shí)現(xiàn)主從復(fù)制方法的相關(guān)資料,需要的朋友可以參考下2022-11-11
MySql超長自動(dòng)截?cái)鄬?shí)例詳解
這篇文章主要介紹了MySql超長自動(dòng)截?cái)鄬?shí)例詳解的相關(guān)資料,這里通過實(shí)例來說明如何實(shí)現(xiàn)自動(dòng)截?cái)嗟墓δ?,需要的朋友可以參考?/div> 2017-07-07最新評(píng)論

