2013-12-11 112 views
4

我已經使用Building a RESTful Web Service教程爲我的目的構建WebService。這很容易,但現在我很難配置WebService應該綁定的端口。沒有​​3210或任何在這個項目中配置的東西。任何人都可以給我一個關於如何配置WebService的端口的提示嗎?Spring REST風格Web服務的端口綁定

由於這些細節可能會有幫助。我使用下面的代碼啓動服務器,其中包含@EnableAutoConfiguration標記。配置由Spring Boot完成。

@ComponentScan 
@EnableAutoConfiguration 
public class ServerStarter{ 

public static void main(String[] args) { 
     SpringApplication.run(ServerStarter.class, args); 
    } 
} 

回答

2

對於一個快速和骯髒的解決方案,你可以使用命令行選項參數(source):

--server.port=9000 
+0

該鏈接提供了一些進一步的細節,如添加一個'application.properties'。多謝! – Baschi

+0

有沒有不同的方式來做到這一點? – hipokito

5

要配置您可以設置通過書面server.port和management.port性質的端口同樣,如果你需要指定的管理地址

server.port = 9000 
management.port = 9001 

:位於「的src/main /資源」下的「application.properties」文件中的下列

management.address = 127.0.0.1 

您還可以爲服務器和管理服務器設置更多屬性。請參閱spring-boot的文檔:http://docs.spring.io/spring-boot/docs/current-SNAPSHOT/reference/htmlsingle/