質問編集履歴
2
お礼
title
CHANGED
File without changes
|
body
CHANGED
@@ -76,17 +76,8 @@
|
|
76
76
|
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:693) ~[spring-boot-1.5.4.RELEASE.jar:1.5.4.RELEASE]
|
77
77
|
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:360) ~[spring-boot-1.5.4.RELEASE.jar:1.5.4.RELEASE]
|
78
78
|
at org.springframework.boot.SpringApplication.run(SpringApplication.java:303) ~[spring-boot-1.5.4.RELEASE.jar:1.5.4.RELEASE]
|
79
|
-
at org.springframework.boot.test.context.SpringBootContextLoader.loadContext(SpringBootContextLoader.java:120
|
79
|
+
at org.springframework.boot.test.context.SpringBootContextLoader.loadContext(SpringBootContextLoader.java:120
|
80
|
-
|
80
|
+
|
81
|
-
|
81
|
+
|
82
|
-
|
82
|
+
mainメソッドのあるクラスに@ImportResource("ApplicationContext.xml")だったのですが、@ImportResource("classpath:ApplicationContext.xml")にしなければならなかったようです。
|
83
|
-
at org.springframework.test.context.web.ServletTestExecutionListener.setUpRequestContextIfNecessary(ServletTestExecutionListener.java:189) [spring-test-4.3.9.RELEASE.jar:4.3.9.RELEASE]
|
84
|
-
at org.springframework.test.context.web.ServletTestExecutionListener.prepareTestInstance(ServletTestExecutionListener.java:131) [spring-test-4.3.9.RELEASE.jar:4.3.9.RELEASE]
|
85
|
-
at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:230) [spring-test-4.3.9.RELEASE.jar:4.3.9.RELEASE]
|
86
|
-
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTest(SpringJUnit4ClassRunner.java:228) [spring-test-4.3.9.RELEASE.jar:4.3.9.RELEASE]
|
87
|
-
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner$1.runReflectiveCall(SpringJUnit4ClassRunner.java:287) [spring-test-4.3.9.RELEASE.jar:4.3.9.RELEASE]
|
88
|
-
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) [junit-4.12.jar:4.12]
|
89
|
-
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.methodBlock(SpringJUnit4ClassRunner.java:289) [spring-test-4.3.9.RELEASE.jar:4.3.9.RELEASE]
|
90
|
-
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:247) [spring-test-4.3.9.RELEASE.jar:4.3.9.RELEASE]
|
91
|
-
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:94) [spring-test-4.3.9.RELEASE.jar:4.3.9.RELEASE]
|
92
|
-
|
83
|
+
泣きそうなくらい悩みました。質問に答えてくれてほんとうにありがとうございます。
|
1
ソースコードとログを載せました
title
CHANGED
File without changes
|
body
CHANGED
@@ -9,4 +9,84 @@
|
|
9
9
|
で定義しております。
|
10
10
|
spring bootのバージョンは1.5.4.RELEASE
|
11
11
|
|
12
|
-
どうすればアノテーションで上手く設定できるのかご教示お願い致します。
|
12
|
+
どうすればアノテーションで上手く設定できるのかご教示お願い致します。
|
13
|
+
|
14
|
+
ソースコード(お見せしてはいけないものは〇に変えてあります)
|
15
|
+
```java
|
16
|
+
package com.〇〇〇〇.service;
|
17
|
+
|
18
|
+
import static org.hamcrest.CoreMatchers.equalTo;
|
19
|
+
import static org.junit.Assert.assertThat;
|
20
|
+
|
21
|
+
import java.util.List;
|
22
|
+
|
23
|
+
import org.junit.Test;
|
24
|
+
import org.junit.runner.RunWith;
|
25
|
+
import org.springframework.boot.test.context.SpringBootTest;
|
26
|
+
import org.springframework.test.context.junit4.SpringRunner;
|
27
|
+
|
28
|
+
import com.〇〇〇〇.domain.entity.Mst002Authority;
|
29
|
+
|
30
|
+
|
31
|
+
//@RunWith(SpringJUnit4ClassRunner.class)
|
32
|
+
//@SpringBootConfiguration(GantelApplication.class)
|
33
|
+
//@ContextConfiguration(locations="classpath:ApplicationContext.xml")
|
34
|
+
|
35
|
+
@RunWith(SpringRunner.class)
|
36
|
+
@SpringBootTest
|
37
|
+
public class AuthorityServiceTest {
|
38
|
+
|
39
|
+
// @Autowired
|
40
|
+
// AuthorityService authorityService;
|
41
|
+
|
42
|
+
|
43
|
+
@Test
|
44
|
+
public void 権限を全権取得できる() {
|
45
|
+
AuthorityService authorityService = new AuthorityService();
|
46
|
+
List<Mst002Authority> list = authorityService.getAuthorityAll();
|
47
|
+
assertThat(list.get(0).getAuthorityId(), equalTo("A10"));
|
48
|
+
assertThat(list.get(0).getAuthorityName(), equalTo("〇〇"));
|
49
|
+
assertThat(list.get(1).getAuthorityId(), equalTo("A20"));
|
50
|
+
assertThat(list.get(1).getAuthorityName(), equalTo("〇〇"));
|
51
|
+
assertThat(list.get(2).getAuthorityId(), equalTo("A30"));
|
52
|
+
assertThat(list.get(2).getAuthorityName(), equalTo("〇〇"));
|
53
|
+
assertThat(list.get(3).getAuthorityId(), equalTo("A40"));
|
54
|
+
assertThat(list.get(3).getAuthorityName(), equalTo("〇〇"));
|
55
|
+
}
|
56
|
+
}
|
57
|
+
```
|
58
|
+
|
59
|
+
2018-04-17 01:51:25.413 ERROR 5500 --- [ main] o.s.boot.SpringApplication : Application startup failed
|
60
|
+
|
61
|
+
org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from ServletContext resource [/ApplicationContext.xml]; nested exception is java.io.FileNotFoundException: Could not open ServletContext resource [/ApplicationContext.xml]
|
62
|
+
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:344) ~[spring-beans-4.3.9.RELEASE.jar:4.3.9.RELEASE]
|
63
|
+
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:304) ~[spring-beans-4.3.9.RELEASE.jar:4.3.9.RELEASE]
|
64
|
+
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:181) ~[spring-beans-4.3.9.RELEASE.jar:4.3.9.RELEASE]
|
65
|
+
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:217) ~[spring-beans-4.3.9.RELEASE.jar:4.3.9.RELEASE]
|
66
|
+
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:188) ~[spring-beans-4.3.9.RELEASE.jar:4.3.9.RELEASE]
|
67
|
+
at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsFromImportedResources(ConfigurationClassBeanDefinitionReader.java:348) ~[spring-context-4.3.9.RELEASE.jar:4.3.9.RELEASE]
|
68
|
+
at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsForConfigurationClass(ConfigurationClassBeanDefinitionReader.java:142) ~[spring-context-4.3.9.RELEASE.jar:4.3.9.RELEASE]
|
69
|
+
at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitions(ConfigurationClassBeanDefinitionReader.java:116) ~[spring-context-4.3.9.RELEASE.jar:4.3.9.RELEASE]
|
70
|
+
at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:320) ~[spring-context-4.3.9.RELEASE.jar:4.3.9.RELEASE]
|
71
|
+
at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:228) ~[spring-context-4.3.9.RELEASE.jar:4.3.9.RELEASE]
|
72
|
+
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:270) ~[spring-context-4.3.9.RELEASE.jar:4.3.9.RELEASE]
|
73
|
+
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:93) ~[spring-context-4.3.9.RELEASE.jar:4.3.9.RELEASE]
|
74
|
+
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:687) ~[spring-context-4.3.9.RELEASE.jar:4.3.9.RELEASE]
|
75
|
+
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:525) ~[spring-context-4.3.9.RELEASE.jar:4.3.9.RELEASE]
|
76
|
+
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:693) ~[spring-boot-1.5.4.RELEASE.jar:1.5.4.RELEASE]
|
77
|
+
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:360) ~[spring-boot-1.5.4.RELEASE.jar:1.5.4.RELEASE]
|
78
|
+
at org.springframework.boot.SpringApplication.run(SpringApplication.java:303) ~[spring-boot-1.5.4.RELEASE.jar:1.5.4.RELEASE]
|
79
|
+
at org.springframework.boot.test.context.SpringBootContextLoader.loadContext(SpringBootContextLoader.java:120) [spring-boot-test-1.5.4.RELEASE.jar:1.5.4.RELEASE]
|
80
|
+
at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContextInternal(DefaultCacheAwareContextLoaderDelegate.java:98) [spring-test-4.3.9.RELEASE.jar:4.3.9.RELEASE]
|
81
|
+
at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:116) [spring-test-4.3.9.RELEASE.jar:4.3.9.RELEASE]
|
82
|
+
at org.springframework.test.context.support.DefaultTestContext.getApplicationContext(DefaultTestContext.java:83) [spring-test-4.3.9.RELEASE.jar:4.3.9.RELEASE]
|
83
|
+
at org.springframework.test.context.web.ServletTestExecutionListener.setUpRequestContextIfNecessary(ServletTestExecutionListener.java:189) [spring-test-4.3.9.RELEASE.jar:4.3.9.RELEASE]
|
84
|
+
at org.springframework.test.context.web.ServletTestExecutionListener.prepareTestInstance(ServletTestExecutionListener.java:131) [spring-test-4.3.9.RELEASE.jar:4.3.9.RELEASE]
|
85
|
+
at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:230) [spring-test-4.3.9.RELEASE.jar:4.3.9.RELEASE]
|
86
|
+
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTest(SpringJUnit4ClassRunner.java:228) [spring-test-4.3.9.RELEASE.jar:4.3.9.RELEASE]
|
87
|
+
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner$1.runReflectiveCall(SpringJUnit4ClassRunner.java:287) [spring-test-4.3.9.RELEASE.jar:4.3.9.RELEASE]
|
88
|
+
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) [junit-4.12.jar:4.12]
|
89
|
+
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.methodBlock(SpringJUnit4ClassRunner.java:289) [spring-test-4.3.9.RELEASE.jar:4.3.9.RELEASE]
|
90
|
+
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:247) [spring-test-4.3.9.RELEASE.jar:4.3.9.RELEASE]
|
91
|
+
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:94) [spring-test-4.3.9.RELEASE.jar:4.3.9.RELEASE]
|
92
|
+
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) [junit-4.12.jar:4.12]
|