我使用彈簧啓動與Maven,這是我的配置類:如何更改使用spring啓動的embebed-tomcat默認端口?
package hello;
import javax.servlet.MultipartConfigElement;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
@Configuration
@ComponentScan
@EnableAutoConfiguration
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
當應用程序啓動時顯示此行控制檯:
2014-11-06 17:00:55.102 INFO 4669 --- [main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat started on port(s): 8080/http
我想給TomcatEmbedded端口更改爲8081爲案件。 感謝:d
在我的情況,這workds:
mvn exec:java -Dserver.port=8081
– 2017-12-04 10:25:23