質問編集履歴
7
githubのrepositoryを削除した旨を記載
title
CHANGED
File without changes
|
body
CHANGED
@@ -14,8 +14,8 @@
|
|
14
14
|
|
15
15
|
|
16
16
|
[githubにあげたソースコード](https://github.com/yukikoike/sample/tree/faeture_add_authentication)
|
17
|
+
↑repositoryを削除致しました。
|
17
18
|
|
18
|
-
|
19
19
|
■ 起動時のログ
|
20
20
|
```
|
21
21
|
|
6
パッケージ名を変更しました
title
CHANGED
File without changes
|
body
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
spring bootでspring boot securityを使ったログイン認証を実装している途中なのですが、
|
2
2
|
起動時に「Description:
|
3
3
|
|
4
|
-
Field userRepository in co.jp.
|
4
|
+
Field userRepository in co.jp.yuki.koike.sample.domain.service.user.UserDetailsServiceImpl required a bean of type 'co.jp.yuki.koike.sample.domain.service.user.UserRepository' that could not be found.
|
5
5
|
」
|
6
6
|
と表示され、起動できません。
|
7
7
|
恐らく、
|
8
|
-
sample\src\main\java\co\jp\
|
8
|
+
sample\src\main\java\co\jp\yuki\koike\sample\domain\service\user\UserDetailsServiceImpl.java
|
9
9
|
か、
|
10
|
-
sample\src\main\java\co\jp\
|
10
|
+
sample\src\main\java\co\jp\yuki\koike\sample\domain\service\user\UserRepository.java
|
11
11
|
に原因があると思います。
|
12
12
|
|
13
13
|
githubにあげたものを見てご指摘いただけないでしょうか?
|
@@ -27,8 +27,8 @@
|
|
27
27
|
=========|_|==============|___/=/_/_/_/
|
28
28
|
:: Spring Boot :: (v2.0.1.RELEASE)
|
29
29
|
|
30
|
-
2018-06-20 09:00:37.955 INFO 8960 --- [ main] co.jp.
|
31
|
-
2018-06-20 09:00:37.970 INFO 8960 --- [ main] co.jp.
|
30
|
+
2018-06-20 09:00:37.955 INFO 8960 --- [ main] co.jp.yuki.koike.sample.SampleApplication : Starting SampleApplication on DESKTOP-BD2CRPU with PID 8960 (C:\Users\nec\git\sample\target\classes started by nec in C:\Users\nec\git\sample)
|
31
|
+
2018-06-20 09:00:37.970 INFO 8960 --- [ main] co.jp.yuki.koikr.sample.SampleApplication : No active profile set, falling back to default profiles: default
|
32
32
|
2018-06-20 09:00:38.601 INFO 8960 --- [ main] ConfigServletWebServerApplicationContext : Refreshing org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@61230f6a: startup date [Wed Jun 20 09:00:38 JST 2018]; root of context hierarchy
|
33
33
|
2018-06-20 09:00:45.514 INFO 8960 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
|
34
34
|
2018-06-20 09:00:45.622 INFO 8960 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
|
@@ -55,17 +55,17 @@
|
|
55
55
|
|
56
56
|
Description:
|
57
57
|
|
58
|
-
Field userRepository in co.jp.
|
58
|
+
Field userRepository in co.jp.yuki.koikr.sample.domain.service.user.UserDetailsServiceImpl required a bean of type 'co.jp.yuki.koikr.sample.domain.service.user.UserRepository' that could not be found.
|
59
59
|
|
60
60
|
|
61
61
|
Action:
|
62
62
|
|
63
|
-
Consider defining a bean of type 'co.jp.
|
63
|
+
Consider defining a bean of type 'co.jp.yuki.koike.sample.domain.service.user.UserRepository' in your configuration.
|
64
64
|
```
|
65
65
|
|
66
66
|
■ UserDetailsServiceImpl.java
|
67
67
|
```java
|
68
|
-
package co.jp.
|
68
|
+
package co.jp.yuki.koike.sample.domain.service.user;
|
69
69
|
|
70
70
|
import java.util.Optional;
|
71
71
|
|
@@ -75,7 +75,7 @@
|
|
75
75
|
import org.springframework.security.core.userdetails.UsernameNotFoundException;
|
76
76
|
import org.springframework.stereotype.Service;
|
77
77
|
|
78
|
-
import co.jp.
|
78
|
+
import co.jp.yuki.koike.sample.domain.model.User;
|
79
79
|
|
80
80
|
@Service
|
81
81
|
public class UserDetailsServiceImpl implements UserDetailsService {
|
@@ -97,11 +97,11 @@
|
|
97
97
|
|
98
98
|
■ UserRepository.java
|
99
99
|
```java
|
100
|
-
package co.jp.
|
100
|
+
package co.jp.yuki.koike.sample.domain.service.user;
|
101
101
|
|
102
102
|
import org.springframework.data.jpa.repository.JpaRepository;
|
103
103
|
|
104
|
-
import co.jp.
|
104
|
+
import co.jp.yuki.koike.sample.domain.model.User;
|
105
105
|
|
106
106
|
public interface UserRepository extends JpaRepository<User, String> {
|
107
107
|
|
5
ソースコードを記載
title
CHANGED
File without changes
|
body
CHANGED
@@ -61,4 +61,51 @@
|
|
61
61
|
Action:
|
62
62
|
|
63
63
|
Consider defining a bean of type 'co.jp.g.n.sample.domain.service.user.UserRepository' in your configuration.
|
64
|
+
```
|
65
|
+
|
66
|
+
■ UserDetailsServiceImpl.java
|
67
|
+
```java
|
68
|
+
package co.jp.g.n.sample.domain.service.user;
|
69
|
+
|
70
|
+
import java.util.Optional;
|
71
|
+
|
72
|
+
import org.springframework.beans.factory.annotation.Autowired;
|
73
|
+
import org.springframework.security.core.userdetails.UserDetails;
|
74
|
+
import org.springframework.security.core.userdetails.UserDetailsService;
|
75
|
+
import org.springframework.security.core.userdetails.UsernameNotFoundException;
|
76
|
+
import org.springframework.stereotype.Service;
|
77
|
+
|
78
|
+
import co.jp.g.n.sample.domain.model.User;
|
79
|
+
|
80
|
+
@Service
|
81
|
+
public class UserDetailsServiceImpl implements UserDetailsService {
|
82
|
+
|
83
|
+
@Autowired
|
84
|
+
UserRepository userRepository;
|
85
|
+
|
86
|
+
|
87
|
+
@Override
|
88
|
+
public UserDetails loadUserByUsername(String username)
|
89
|
+
throws UsernameNotFoundException {
|
90
|
+
User user = Optional.ofNullable(userRepository.findOne(username))
|
91
|
+
.orElseThrow(() -> new UsernameNotFoundException(username + " is not found."));
|
92
|
+
return new UserDetailsImpl(user);
|
93
|
+
}
|
94
|
+
}
|
95
|
+
|
96
|
+
```
|
97
|
+
|
98
|
+
■ UserRepository.java
|
99
|
+
```java
|
100
|
+
package co.jp.g.n.sample.domain.service.user;
|
101
|
+
|
102
|
+
import org.springframework.data.jpa.repository.JpaRepository;
|
103
|
+
|
104
|
+
import co.jp.g.n.sample.domain.model.User;
|
105
|
+
|
106
|
+
public interface UserRepository extends JpaRepository<User, String> {
|
107
|
+
|
108
|
+
User findOne(String username);
|
109
|
+
}
|
110
|
+
|
64
111
|
```
|
4
リンクを修正致しました
title
CHANGED
File without changes
|
body
CHANGED
@@ -13,8 +13,7 @@
|
|
13
13
|
githubにあげたものを見てご指摘いただけないでしょうか?
|
14
14
|
|
15
15
|
|
16
|
-
■ githubにあげたソースコード
|
17
|
-
[https://github.com/yukikoike/sample/tree/faeture_add_authentication
|
16
|
+
[githubにあげたソースコード](https://github.com/yukikoike/sample/tree/faeture_add_authentication)
|
18
17
|
|
19
18
|
|
20
19
|
■ 起動時のログ
|
3
リンクを記載致しました。
title
CHANGED
File without changes
|
body
CHANGED
@@ -14,7 +14,7 @@
|
|
14
14
|
|
15
15
|
|
16
16
|
■ githubにあげたソースコード
|
17
|
-
https://github.com/yukikoike/sample/tree/faeture_add_authentication
|
17
|
+
[https://github.com/yukikoike/sample/tree/faeture_add_authentication]
|
18
18
|
|
19
19
|
|
20
20
|
■ 起動時のログ
|
2
<code>でログを囲いました
title
CHANGED
File without changes
|
body
CHANGED
@@ -18,7 +18,7 @@
|
|
18
18
|
|
19
19
|
|
20
20
|
■ 起動時のログ
|
21
|
-
|
21
|
+
```
|
22
22
|
|
23
23
|
. ____ _ __ _ _
|
24
24
|
/\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
|
@@ -62,6 +62,4 @@
|
|
62
62
|
Action:
|
63
63
|
|
64
64
|
Consider defining a bean of type 'co.jp.g.n.sample.domain.service.user.UserRepository' in your configuration.
|
65
|
-
|
66
|
-
|
67
|
-
|
65
|
+
```
|
1
誤記がありました。
title
CHANGED
File without changes
|
body
CHANGED
@@ -64,7 +64,4 @@
|
|
64
64
|
Consider defining a bean of type 'co.jp.g.n.sample.domain.service.user.UserRepository' in your configuration.
|
65
65
|
|
66
66
|
|
67
|
-
---------------------------------------
|
67
|
+
---------------------------------------
|
68
|
-
|
69
|
-
■ githubにあげたソースコード
|
70
|
-
https://github.com/yukikoike/sample/tree/faeture_add_authentication
|