Jython2.7.2中提示URIisnothierarchical怎么辦

這篇文章主要為大家展示了“Jython 2.7.2中提示URI is not hierarchical怎么辦”,內(nèi)容簡而易懂,條理清晰,希望能夠幫助大家解決疑惑,下面讓小編帶領(lǐng)大家一起研究并學(xué)習(xí)一下“Jython 2.7.2中提示URI is not hierarchical怎么辦”這篇文章吧。

公司主營業(yè)務(wù):成都網(wǎng)站設(shè)計(jì)、成都網(wǎng)站建設(shè)、移動網(wǎng)站開發(fā)等業(yè)務(wù)。幫助企業(yè)客戶真正實(shí)現(xiàn)互聯(lián)網(wǎng)宣傳,提高企業(yè)的競爭能力。創(chuàng)新互聯(lián)是一支青春激揚(yáng)、勤奮敬業(yè)、活力青春激揚(yáng)、勤奮敬業(yè)、活力澎湃、和諧高效的團(tuán)隊(duì)。公司秉承以“開放、自由、嚴(yán)謹(jǐn)、自律”為核心的企業(yè)文化,感謝他們對我們的高要求,感謝他們從不同領(lǐng)域給我們帶來的挑戰(zhàn),讓我們激情的團(tuán)隊(duì)有機(jī)會用頭腦與智慧不斷的給客戶帶來驚喜。創(chuàng)新互聯(lián)推出鹿城免費(fèi)做網(wǎng)站回饋大家。

1 .背景

由于需要使用Jython。但是發(fā)現(xiàn)一個(gè)詭異的現(xiàn)象IDE使用沒有問題,但是打包jar報(bào)錯(cuò)。

            Properties props = new Properties();
            props.put("python.home","D:\\jython2.7.2");
            props.put("python.path","D:\\jython2.7.2\\Lib\\site-packages");
            props.put("python.console.encoding", "UTF-8"); // Used to prevent: console: Failed to install '': java.nio.charset.UnsupportedCharsetException: cp0.
            props.put("python.security.respectJavaAccessibility", "false"); //don't respect java accessibility, so that we can access protected members on subclasses
            props.put("python.import.site","false");
            //props.put("python.cachedir.skip","true");

            props.put("org.python.netty.noUnsafe","true");

            Properties preprops = System.getProperties();

            PythonInterpreter.initialize(preprops, props, new String[0]);// 此處報(bào)異常

            PythonInterpreter pyInterp = new PythonInterpreter();
java.lang.IllegalArgumentException: URI is not hierarchical
        at java.io.File.<init>(File.java:418)
        at org.python.core.PrePy.getJarFileNameFromURL(PrePy.java:427)
        at org.python.core.PrePy._getJarFileName(PrePy.java:362)
        at org.python.core.PrePy.getJarFileName(PrePy.java:345)
        at org.python.core.PySystemState.doInitialize(PySystemState.java:1195)
        at org.python.core.PySystemState.initialize(PySystemState.java:1130)
        at org.python.core.PySystemState.initialize(PySystemState.java:1085)
        at org.python.core.PySystemState.initialize(PySystemState.java:1080)
        at org.python.util.PythonInterpreter.initialize(PythonInterpreter.java:63)
        at com.langtutu.ncs.api.robot.core.Test.<init>(Test.java:34)
        at com.langtutu.ncs.api.service.impl.HomestaySchedulingServiceImpl.DownOrderTest(HomestaySchedulingServiceImpl.java:90)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.springframework.scheduling.support.ScheduledMethodRunnable.run(ScheduledMethodRunnable.java:84)
        at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54)
        at org.springframework.scheduling.concurrent.ReschedulingRunnable.run(ReschedulingRunnable.java:93)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)

2. 問題查找

使用IDE和遠(yuǎn)程調(diào)用分別調(diào)試跟蹤了一下jython,定位到代碼報(bào)錯(cuò)行: Jython 2.7.2中提示URI is not hierarchical怎么辦

  • IDE調(diào)試 發(fā)現(xiàn)url是如下的: jar:file:/D:/maven/apache-maven-3.3.9/repository/org/python/jython/2.7.2/jython-2.7.2.jar!/org/python/core/PrePy.class

  • 遠(yuǎn)程調(diào)試

Jython 2.7.2中提示URI is not hierarchical怎么辦

嵌套不能用。

3. 解決方案:

maven打包時(shí)候?qū)ython剔除;運(yùn)行時(shí)候加載外部jar包即可。

剔除:

<build>
		<plugins>
			<plugin>
				<groupId>org.springframework.boot</groupId>
				<artifactId>spring-boot-maven-plugin</artifactId>
				<version>2.2.10.RELEASE</version>
				<configuration>
					<layout>ZIP</layout>
					<!--去除在生產(chǎn)環(huán)境中不變的依賴 多個(gè)用逗號隔開,-->
					<excludeGroupIds>
						org.python
					</excludeGroupIds>
				</configuration>
			</plugin>
		</plugins>
	</build>

運(yùn)行:

java -Dloader.path="lib/" -jar .\ncsapi-0.0.1-SNAPSHOT.jar

lib里面就是jar包。此時(shí)運(yùn)行完全正常

以上是“Jython 2.7.2中提示URI is not hierarchical怎么辦”這篇文章的所有內(nèi)容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內(nèi)容對大家有所幫助,如果還想學(xué)習(xí)更多知識,歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道!

文章名稱:Jython2.7.2中提示URIisnothierarchical怎么辦
文章出自:http://bm7419.com/article44/gocpee.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供建站公司、域名注冊、企業(yè)建站、標(biāo)簽優(yōu)化、企業(yè)網(wǎng)站制作、網(wǎng)站設(shè)計(jì)公司

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)

小程序開發(fā)