用war包布署 经常要重启tomcat而且一旦其中一块出问题,会导致整个tomcat全部killed ,为此改用jar部署,但是这时候,为了都能从80端口进行访问,就需要加一个路由模块
这里只是最很简单的转发,不进行负载均衡,所以不需要使用,注册中心
需要注意的就是部署的时候这些包(zuul+ribbon+hystrix)如果不放进去,并不会报错,但是i不转发 , 所以需要记得把这些包放上去
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-zuul</artifactId>
</dependency>
zuul:
ignored-services: "*"
routes:
battery_charging:
path: /battery_charging/api/**
url: http://localhost:5000/
# stripPrefix:
sensitiveHeaders:
ignoredHeaders:
ribbon:
eureka:
enabled: false
spring:
#没有绑定的url直接抛出错误
mvc.throw-exception-if-no-handler-found: true
#不为静态文件建立映射
resources.add-mappings: false
autoconfigure: #这种写法似乎只支持排除一个,为了排除多个需要在主类代码里边进行排除
exclude: org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration, org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration
#exclude:
# - org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration
# - org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration
jmx:
enabled: false
logging:
level:
root: debug
@SpringBootApplication/*(exclude = {
org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration.class,
org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration.class})*/
//@EnableEurekaClient
@EnableZuulProxy
public class CitylinkRouteApplication {
// org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration
public static void main(String[] args) {
SpringApplication.run(CitylinkRouteApplication.class, args);
}
}