当运行ionic build android时
ANDROID_HOME=/Library/Android/sdk
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_92.jdk/Contents/Home
Error: Could not find gradle wrapper within Android SDK. Might need to update your Android SDK.
Looked here: /Library/Android/sdk/tools/templates/gradle/wrapper
Run Code Online (Sandbox Code Playgroud)
我尝试使用android update sdk -u更新sdk
我有一个使用 .net core 3.1 运行的项目。升级到 .net 5 并将实体框架核心升级到 5.0.3 后,包含不再起作用。
我有这些课程
public class Question
{
[Key]
public Guid Id { get; set; }
public string QuestionCode { get; set; }
[ForeignKey("AnswersId")]
public Answer Answers { get; set; }
}
public class Answer
{
[Key]
public Guid Id { get; set; }
public string Answers { get; set; }
public int Score { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
该关系定义如下:
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<Question>()
.HasOne(q => q.Answers);
}
Run Code Online (Sandbox Code Playgroud)
以及这个简单的 LINQ: …
我在应用程序中有 2 个中间件。我想从这些中间件中排除一条路线。我尝试过的是创建一个 BuildRouter 函数并通过它应用中间件,但这不起作用。
public IRouter BuildRouter(IApplicationBuilder applicationBuilder)
{
var builder = new RouteBuilder(applicationBuilder);
builder.MapMiddlewareRoute("/api/", appBuilder => {
appBuilder.ApplyKeyValidation();
appBuilder.ApplyPolicyValidation();
});
return builder.Build();
}
Run Code Online (Sandbox Code Playgroud)
而配置方法是
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
else
{
app.UseHsts();
}
app.UseRouter(BuildRouter(app));
app.UseHttpsRedirection();
app.UseMvc();
}
Run Code Online (Sandbox Code Playgroud)
但这是行不通的。
我在.Net Core 2中遇到中间件问题。中间件无法处理任何即将到来的请求。我已经实现了。
KeyValidatorMiddleware类:
public class KeyValidatorMiddleware
{
private readonly RequestDelegate _next;
public KeyValidatorMiddleware(RequestDelegate next)
{
_next = next;
}
public async Task Invoke(HttpContext context)
{
if (!context.Request.Headers.ContainsKey("api-key"))
{
context.Response.StatusCode = 401;
await context.Response.WriteAsync("No API key found !");
return;
}
await _next.Invoke(context);
}
}
Run Code Online (Sandbox Code Playgroud)
并在Startup.cs中
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
else
{
app.UseHsts();
}
app.UseHttpsRedirection();
app.UseMvc();
app.UseCors("MyPolicy");
app.UseMiddleware<KeyValidatorMiddleware>();
}
Run Code Online (Sandbox Code Playgroud)
没有任何效果,为了使中间件正常工作,我缺少什么?