質問編集履歴
2
HelloService, HelloResponse追加しました
test
CHANGED
File without changes
|
test
CHANGED
@@ -89,3 +89,89 @@
|
|
89
89
|
|
90
90
|
|
91
91
|
設定等疑わしいところアドバイスいただけたらと思います。
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
HelloService.java
|
96
|
+
|
97
|
+
```Java
|
98
|
+
|
99
|
+
package myapi.service;
|
100
|
+
|
101
|
+
|
102
|
+
|
103
|
+
import javax.ws.rs.GET;
|
104
|
+
|
105
|
+
import javax.ws.rs.Path;
|
106
|
+
|
107
|
+
import javax.ws.rs.Produces;
|
108
|
+
|
109
|
+
import javax.ws.rs.core.MediaType;
|
110
|
+
|
111
|
+
|
112
|
+
|
113
|
+
import org.springframework.stereotype.Service;
|
114
|
+
|
115
|
+
@Service
|
116
|
+
|
117
|
+
@Path("/jax-rs")
|
118
|
+
|
119
|
+
public class HelloService
|
120
|
+
|
121
|
+
{
|
122
|
+
|
123
|
+
@GET
|
124
|
+
|
125
|
+
@Produces(MediaType.APPLICATION_JSON)
|
126
|
+
|
127
|
+
public HelloResponse hello()
|
128
|
+
|
129
|
+
{
|
130
|
+
|
131
|
+
HelloResponse res = new HelloResponse();
|
132
|
+
|
133
|
+
res.setResult("AAA");
|
134
|
+
|
135
|
+
return res;
|
136
|
+
|
137
|
+
}
|
138
|
+
|
139
|
+
}
|
140
|
+
|
141
|
+
```
|
142
|
+
|
143
|
+
|
144
|
+
|
145
|
+
HelloResponse.java
|
146
|
+
|
147
|
+
```Java
|
148
|
+
|
149
|
+
package myapi.response;
|
150
|
+
|
151
|
+
|
152
|
+
|
153
|
+
import lombok.Getter;
|
154
|
+
|
155
|
+
import lombok.NoArgsConstructor;
|
156
|
+
|
157
|
+
import lombok.Setter;
|
158
|
+
|
159
|
+
|
160
|
+
|
161
|
+
@NoArgsConstructor
|
162
|
+
|
163
|
+
public class HelloResponse
|
164
|
+
|
165
|
+
{
|
166
|
+
|
167
|
+
|
168
|
+
|
169
|
+
@Getter
|
170
|
+
|
171
|
+
@Setter
|
172
|
+
|
173
|
+
public String result;
|
174
|
+
|
175
|
+
}
|
176
|
+
|
177
|
+
```
|
1
中途の投稿を清書
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
SpringBoot + jersey で、@Configuration をつけると
|
1
|
+
SpringBoot + jersey で、@Configuration をつけるとgradle buildでtestがエラー
|
test
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
※ 途中で投稿されていました。すみません。
|
2
|
+
|
3
|
+
|
4
|
+
|
1
5
|
jersey の ResourceConfig を継承した、Configクラスに、@Configuration アノテーションをつけるとランタイムエラーになります。
|
2
6
|
|
3
7
|
|
@@ -38,10 +42,50 @@
|
|
38
42
|
|
39
43
|
|
40
44
|
|
41
|
-
エラー内容
|
45
|
+
エラー内容(gradle build のtestタスク):StackTraceの一部は加工しています
|
46
|
+
|
47
|
+
```
|
48
|
+
|
49
|
+
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jerseyConfig' defined in file [***/config/JerseyConfig.class]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [myapi.config.JerseyConfig$$EnhancerBySpringCGLIB$$db4dedf9]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError: com/google/common/base/Function
|
50
|
+
|
51
|
+
|
52
|
+
|
53
|
+
2019-05-01 06:55:26.141 ERROR 22121 --- [ Test worker] o.s.test.context.TestContextManager : Caught exception while allowing TestExecutionListener [org.springframework.test.context.web.ServletTestExecutionListener@7a5b8ae1] to prepare test instance [rex.hows.jsb.jsbhows.DemoApplicationTests@7183be67]
|
54
|
+
|
55
|
+
|
56
|
+
|
57
|
+
java.lang.IllegalStateException: Failed to load ApplicationContext
|
58
|
+
|
59
|
+
at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:125) ~[spring-test-5.1.6.RELEASE.jar:5.1.6.RELEASE]
|
60
|
+
|
61
|
+
|
62
|
+
|
63
|
+
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jerseyConfig' defined in file [***/config/JerseyConfig.class]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [myapi.config.JerseyConfig$$EnhancerBySpringCGLIB$$db4dedf9]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError: com/google/common/base/Function
|
64
|
+
|
65
|
+
|
66
|
+
|
67
|
+
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [myapi.config.JerseyConfig$$EnhancerBySpringCGLIB$$db4dedf9]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError: com/google/common/base/Function
|
68
|
+
|
69
|
+
|
70
|
+
|
71
|
+
Caused by: java.lang.NoClassDefFoundError: com/google/common/base/Function
|
72
|
+
|
73
|
+
at org.glassfish.jersey.server.ResourceConfig.<init>(ResourceConfig.java:338) ~[jaxrs-ri-2.0.1.jar:2.0.]
|
74
|
+
|
75
|
+
at myapi.JerseyConfig.<init>(JerseyConfig.java:12) ~[main/:na]
|
76
|
+
|
77
|
+
at myapi.config.JerseyConfig$$EnhancerBySpringCGLIB$$db4dedf9.<init>(<generated>) ~[main/:na]
|
78
|
+
|
79
|
+
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[na:na]
|
80
|
+
|
81
|
+
|
82
|
+
|
83
|
+
Caused by: java.lang.ClassNotFoundException: com.google.common.base.Function
|
84
|
+
|
85
|
+
|
42
86
|
|
43
87
|
```
|
44
88
|
|
45
89
|
|
46
90
|
|
47
|
-
|
91
|
+
設定等疑わしいところアドバイスいただけたらと思います。
|