我已经通过Kafka使用Spring Cloud Bus构建了一个集成的Spring Cloud Config Server,用于动态刷新属性。我还有一个Spring Cloud Gateway应用程序,它使用这些属性并动态刷新它们。
我正在努力解决的事情之一是,如果我(无意间)在Spring Gateway路由中更新了错误的属性(例如:public class Startup
{
public Startup(IConfiguration configuration)
{
Configuration = configuration;
}
public IConfiguration Configuration { get; }
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
services.AddCors(o => o.AddPolicy("ThePolicy", builder =>
{
builder.AllowAnyOrigin()
.AllowAnyMethod()
.AllowAnyHeader();
}));
//services.AddCors(c =>
//{
// c.AddPolicy("AllowOrigin", options => options.AllowAnyOrigin());
//});
ConfigureServicesModule<AviationIQ_Dev_Phase2Context>.Register(services, Configuration);
services.Configure<FormOptions>(o => {
o.ValueLengthLimit = int.MaxValue;
o.MultipartBodyLengthLimit = int.MaxValue;
o.MemoryBufferThreshold = int.MaxValue;
});
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
else
{
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
app.UseHsts();
}
//app.UseHttpsRedirection();
//app.UseMvc();
ConfigureModule.Configure(app, env, Configuration);
app.UseCors("ThePolicy");
}
}
,这里的反斜杠是错误的)。
路由在Spring Cloud Gateway中中断,并出现诸如无法初始化bean spring.cloud.gateway.routes[0].predicates[0]=Path=/demo/{demoId\:[0-9]+}
之类的错误,事情开始变得怪异。
两个问题: