-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDemoApplication.java
61 lines (45 loc) · 1023 Bytes
/
DemoApplication.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package com.example.demo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
import java.util.List;
@SpringBootApplication
public class DemoApplication {
public static void main(String[] args) {
SpringApplication.run(DemoApplication.class, args);
}
interface A {
void doA();
}
interface B {
void doB();
}
@Service
static class SomeService {
@Autowired
public <T extends A & B> SomeService(List<T> impls) {
impls.forEach(s -> {
s.doA();
s.doB();
});
}
}
@Component
static class AwithB implements A, B {
@Override
public void doA() {
}
@Override
public void doB() {
}
}
@Component
static class AwithoutB implements A {
@Override
public void doA() {
}
}
}