尝试运行我的应用程序时出现以下问题.调试了一切,但仍然没有.
IDE正在寻找没有任何问题的bean,所以我对这里发生的事情感到非常困惑.
SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mailManager': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire method: public void com.testmail.app.service.implement.CustomMManagerService.setMailSender(org.springframework.mail.javamail.JavaMailSender); nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [org.springframework.mail.javamail.JavaMailSender] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {}
Run Code Online (Sandbox Code Playgroud)
我的bean生成位于以下文件中:
@Configuration
@EnableWebMvc
@ComponentScan(basePackages = "com.testmail.app")
public class WebConfig extends WebMvcConfigurerAdapter {
//CODE CODE …Run Code Online (Sandbox Code Playgroud) 好的多个问题在这里:
你什么时候选择一个而不是另一个?
如果你选择一个而不是一致性,这有关系吗?
我正在学习IdentityServer4 https://identityserver4.readthedocs.io/en/release/quickstarts/0_overview.html,但似乎遇到了让它运行的问题.
在创建项目的API部分并进行相应配置之后:
public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory)
{
loggerFactory.AddConsole(Configuration.GetSection("Logging"));
loggerFactory.AddDebug();
app.UseIdentityServerAuthentication(new IdentityServerAuthenticationOptions
{
Authority = "http://localhost:5000",
RequireHttpsMetadata = false,
ApiName = "api1"
});
app.UseMvc();
}
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:
'IApplicationBuilder' does not contain a definition for 'UseIdentityServerAuthentication' and no extension method 'UseIdentityServerAuthentication' accepting a first argument of type 'IApplicationBuilder' could be found (are you missing a using directive or an assembly reference?)
Run Code Online (Sandbox Code Playgroud)
我在这里缺少什么建议?
编辑1:我注意到即使软件包已安装并存在,我也无法引用命名空间.
即
using IdentityServer4.AccessTokenValidation;
Run Code Online (Sandbox Code Playgroud)
要么
using IdentityServer4;
Run Code Online (Sandbox Code Playgroud) 我希望能够根据 URL 路由更改页面上的数据,即 test/1 获取数据集 1,test/2 获取数据集 2。但是,如果我已经在 test/1 上并尝试导航到test/2 (反之亦然)使用路由器导航,它更改了 url,但仅此而已,没有其他内容被触发。
我的路线有以下定义:
const routes: Routes = [
{
path: 'test',
children: [
{
path: ':id',
component: TestComponent
},
{ path: '**', redirectTo: '', pathMatch: 'full' }
]
},
];
Run Code Online (Sandbox Code Playgroud)
TS 组件:
value: any;
constructor(private router: Router, private, private route: ActivatedRoute) {
this.value = this.route.snapshot.params.id;
}
goToPage(value: any) {
this.router.navigate(['/test', value]);
}
Run Code Online (Sandbox Code Playgroud)
我的 html 组件:
{{value}}
<button (click)="goToPage(1)">One</button>
<button (click)="goToPage(2)">Two</button>
Run Code Online (Sandbox Code Playgroud)
我还尝试将 { onSameUrlNavigation: 'reload' } 添加到 RouterModule.forRoot,但仍然没有执行任何操作。
注意:问题不在于获取参数,问题在于必须刷新页面才能触发与新参数关联的所有进程。
我有一个我在业余时间建造的简单任务项目.由组成:
我现在正试图通过整合移动应用程序来扩展它.在这种情况下,我在Ionic中构建了一个显示任务的简单应用程序.我现在想要实现身份验证,以便它可以从API获取与该用户相关的任务.
我一直在环顾四周,但找不到任何解释如何做到这一点或任何证明这一点的例子.
结束状态它将是一个Android应用程序.
任何帮助表示赞赏.
更新1:
我已经研究过利用oidc-client但是在移植到Android时似乎没有正确激活浏览器功能.尽管如此,对于正确的方法以及如何做到这一点,还没有找到足够的信息.
更新2:功能请求到Ionic 由于似乎有很多人受此影响我已经在Github中与Ionic团队提出了功能请求. https://github.com/ionic-team/ionic/issues/14499
请投票和评论.
AddPooledDbContextFactory我最近在 NET 5 自学文章中发现了这个概念,并热衷于正确实施它。但是,我不确定如何将它与我通常使用的泛型一起使用。
我当前的设置示例:
public void ConfigureServices(IServiceCollection services)
{
services.AddDbContext<TestDbContext>(
(s, o) => o.UseNpgsql(Configuration.GetConnectionString("DatabaseConnection"))
.UseLoggerFactory(s.GetRequiredService<ILoggerFactory>()));
// other code //
}
Run Code Online (Sandbox Code Playgroud)
我的存储库通用:
public class Repository<T> : IRepository<T> where T
{
private readonly TestDbContext _dbContext;
public Repository(TestDbContext dbContext)
{
_dbContext = dbContext;
}
public async Task Create(T entity)
{
await _dbContext.Set<T>().AddAsync(entity);
await _dbContext.SaveChangesAsync();
}
// other methods //
}
Run Code Online (Sandbox Code Playgroud)
作为示例,这是通过以下方式调用的:
public class WeatherForecastController : ControllerBase
{
private readonly IRepository<Test> testRepo;
public WeatherForecastController(IRepository<Test> testRepo)
{
this.testRepo= testRepo;
}
[HttpGet]
public async …Run Code Online (Sandbox Code Playgroud) c# entity-framework entity-framework-core asp.net-core .net-5
我是Spring的新手,所以我一直在寻找安全方面的东西.每次我运行我的应用程序时,我得到:
org.springframework.beans.factory.BeanCreationException:创建名为'securityConfig'的bean时出错:注入自动连接的依赖项失败; 嵌套异常是org.springframework.beans.factory.BeanCreationException:无法自动装配字段:private org.springframework.security.core.userdetails.UserDetailsService com.entirety.app.config.SecurityConfig.userDetailsServiceImplementation; 嵌套异常是org.springframework.beans.factory.NoSuchBeanDefinitionException:没有为依赖项找到类型[org.springframework.security.core.userdetails.UserDetailsService]的限定bean:期望至少有一个bean符合此依赖项的autowire候选资格.依赖注释:{@ org.springframework.beans.factory.annotation.Autowired(required = true)}
我用精梳梳理了我的代码,无法查明问题.
Spring Framework版本:3.2.5.RELEASE Spring Security版本:3.2.0.M2
SecurityConfig.java
package com.entirety.app.config;
import com.entirety.app.service.implement.UserDetailsServiceImplementation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import javax.sql.DataSource;
@Configuration
@EnableWebSecurity
@EnableGlobalMethodSecurity(prePostEnabled=true)
public class SecurityConfig extends WebSecurityConfigurerAdapter {
@Autowired
private DataSource dataSource;
@Autowired
private UserDetailsService userDetailsServiceImplementation;
@Override
protected void registerAuthentication(AuthenticationManagerBuilder auth) throws Exception {
auth.jdbcAuthentication().dataSource(dataSource);
}
@Override
protected void configure(HttpSecurity http) throws Exception {
http.userDetailsService(userDetailsServiceImplementation)
.authorizeUrls()
.antMatchers("/admin/**").hasRole("ADMIN")
.antMatchers("/sec/**").hasRole("MODERATOR")
.antMatchers("/*").permitAll()
.anyRequest().anonymous().and().exceptionHandling().accessDeniedPage("/denied").and() …Run Code Online (Sandbox Code Playgroud) 我创建了一个简单的嵌套表单,它依赖于子组件,而不是将所有内容都放入一个组件中。我已经实现了一个非常基本的 ControlValueAccessor 以使其能够以这种方式工作,但是我注意到验证不会在父组件中捕获。这意味着即使表单无效,也可以提交错误的表单。
我如何获得子表单的验证以传播到父表单。
下面是代码。
父 HTML
<form [formGroup]="parentForm" (ngSubmit)="submitData()">
<h3>Parent</h3>
<br>
<ng-container formArrayName="children">
<ng-container *ngFor="let c of children?.controls; index as j">
<app-child [formControlName]="j"></app-child>
</ng-container>
</ng-container>
<button mat-raised-button type="button" (click)="addChild()">Add Activity</button>
<button mat-raised-button type="submit" color="warn" [disabled]="!parentForm.valid">Submit</button>
</form>
<pre>
{{parentForm.valid}} // this is always true because its not getting validator state from children
</pre>
<pre>
{{parentForm.value | json}}
</pre>
Run Code Online (Sandbox Code Playgroud)
父 TS
export class ParentComponent implements OnInit {
parentForm: FormGroup;
constructor(private fb: FormBuilder) {
}
ngOnInit(): void {
this.createForm();
}
private createForm() …Run Code Online (Sandbox Code Playgroud) 我想弄清楚如何在 .NET Web Api 2 中实现全局异常处理程序。
我尝试按照 Microsoft 此处列出的示例进行操作:https : //docs.microsoft.com/en-us/aspnet/web-api/overview/error-handling/web-api-global-error-handling
但是当异常发生时,它什么也没做。
这是我的代码:
public class GlobalExceptionHandler : ExceptionHandler
{
public override void Handle(ExceptionHandlerContext context)
{
Trace.WriteLine(context.Exception.Message);
context.Result = new TextPlainErrorResult
{
Request = context.ExceptionContext.Request,
Content = "Oops! Sorry! Something went wrong." +
"Please contact support@testme.com so we can try to fix it."
};
}
private class TextPlainErrorResult : IHttpActionResult
{
public HttpRequestMessage Request { private get; set; }
public string Content { private get; set; }
public Task<HttpResponseMessage> ExecuteAsync(CancellationToken …Run Code Online (Sandbox Code Playgroud) 我复制了 Angular 6 Material autocomplete 简单示例: Simple Autocomplete
我试图弄清楚一旦做出选择,如何移除焦点。
我添加了以下更改:
在 HTML 中
<mat-autocomplete #autoGroup="matAutocomplete" (optionSelected)="onSelectionChanged($event)">
Run Code Online (Sandbox Code Playgroud)
在组件中
onSelectionChanged(event: MatAutocompleteSelectedEvent) {
console.log(event.option.value);
}
Run Code Online (Sandbox Code Playgroud)
在将值输出到控制台后,我想从输入字段中移除焦点,但不确定如何执行此操作。
angular ×4
asp.net ×2
asp.net-core ×2
c# ×2
java ×2
spring ×2
typescript ×2
.net-5 ×1
api ×1
autowired ×1
spring-mvc ×1