怎么設(shè)置Eclipse 的 J2EE Preview Server 端口呢?這里給大家?guī)?lái)的是Eclipse J2EE Preview Server 端口設(shè)置方法,一起來(lái)看看吧。
Eclipse J2EE Preview Server 端口設(shè)置方法
最近想在Eclipse測(cè)試一下HTML5,在搭建服務(wù)的時(shí)候糾結(jié)了一下。
系統(tǒng)環(huán)境是Mac,使用的的Eclipse是 eclipse-jee-luna-SR1-macosx-cocoa-x86_64.tar.gz 這個(gè)版本,WTP組件是集成的,那么問(wèn)題就來(lái)了,由于只是測(cè)試HTML,不想搭Tomcat(網(wǎng)上搜索Eclipse HTTP Server 清一色tomcat教程,呃),我想新建的Server是 Basic-J2EE Preview,(其他兩項(xiàng)HTTP Preview、HTTP Server都有點(diǎn)問(wèn)題,前者報(bào)JRE的錯(cuò),后者請(qǐng)求的時(shí)候報(bào)錯(cuò),這個(gè)問(wèn)題看樣子是已經(jīng)被當(dāng)做一個(gè)Bug提交且沒(méi)解決https://bugs.eclipse.org/bugs/show_bug.cgi?id=293398,只有選擇J2EE這個(gè),內(nèi)建的用起來(lái)方便)。
只有J2EE Preview稍微正常一點(diǎn),能控制啟動(dòng),瀏覽器正常訪問(wèn),但是啟動(dòng)時(shí)默認(rèn)端口是8080,而且整個(gè)UI里面都找不到哪里能改這個(gè)端口,需要改的話只能走下面的方法了:
進(jìn)入當(dāng)前項(xiàng)目文件夾的隱藏目錄
workspace/.metadata/.plugins/org.eclipse.wst.server.core
打開(kāi) servers.xml,默認(rèn)內(nèi)容如下:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<servers>
<server hostname="localhost" id="J2EE Preview at localhost" name="J2EE Preview at localhost" runtime-id="J2EE Preview" server-type="org.eclipse.jst.server.preview.server" server-type-id="org.eclipse.jst.server.preview.server" start-timeout="240" stop-timeout="240" timestamp="1">
<list key="modules" value0="HTML::org.eclipse.wst.web.internal.deployables.static:HTML::wst.web::1.0"/>
</server>
</servers>
這就是J2EE Preview的配置文件,那么就手動(dòng)加一個(gè) port 屬性,修改后如下:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<servers>
<server hostname="localhost" port="9090" id="J2EE Preview at localhost" name="J2EE Preview at localhost" runtime-id="J2EE Preview" server-type="org.eclipse.jst.server.preview.server" server-type-id="org.eclipse.jst.server.preview.server" start-timeout="240" stop-timeout="240" timestamp="1">
<list key="modules" value0="HTML::org.eclipse.wst.web.internal.deployables.static:HTML::wst.web::1.0"/>
</server>
</servers>
然后重啟一下eclipse,就能成功訪問(wèn) http://localhost:9090了。