在構建netty的時候遇到一個問題,總是報netty-tcnative包找不到,這就奇了怪了,都是官方的源碼,怎麼會報錯?
結果在maven本地庫裏面發現netty-tcnative包後面總是被加上了系統變量的名字,變成了netty-tcnative-1.1.32.Fork1_x86_64的字樣。
問題就出在下面這個maven配置中:
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>netty-tcnative</artifactId>
<version>1.1.32.Fork1</version>
<classifier>${os.detected.classifier}</classifier>
<scope>compile</scope>
<optional>true</optional>
</dependency>
<classifier>${os.detected.classifier}</classifier>
它相當於是在maven包名字後面再加了一個後綴,用作版本或者特殊化區分的配置。
${os.detected.classifier}就相當於上面的_x86_64。
再進一步,原來netty-tcnative這個包也不屬於netty項目的一部分,而是作爲一個獨立項目發佈的,我猜測應該是作者在開發環境中爲了做跨平臺的時候加的東西吧,因爲裏面有jni,但是正式發佈的時候是沒有後面那些東西的。