0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Springにて、Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)みたいなエラーの解決

Last updated at Posted at 2020-08-13

エラー内容

警告: Exception encountered during context initialization - cancelling refresh attempt: 
org.springframework.beans.factory.UnsatisfiedDependencyException:
 Error creating bean with name '【コントローラー名】': 
Unsatisfied dependency expressed through field '【サービスの変数名】'; 
nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: 
Error creating bean with name '【サービス名】': Unsatisfied dependency 
expressed through field '【dtoの変数名】'; nested exception is 
org.springframework.beans.factory.NoSuchBeanDefinitionException:
 No qualifying bean of type '【パッケージ名を含めたdto名】' available: 
expected at least 1 bean which qualifies as autowire candidate. 
Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)} 

誤ったプログラム

nogizaka-suko.java
@Autowired
private OnlineOrderDto ooDto;

@Autowired
private OnlineOrderDao ooDao;

修正したプログラム

dtoに@Autowiredをつけてしまっていたので外す(dtoは特にアノテーションをつけない普通のjavaのプログラムだから)

nogizaka-suko.java
private OnlineOrderDto ooDto;

private OnlineOrderDao ooDao;

まとめ

誤った場所に@Autowiredをつけないようにする

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?