<dependency>
<groupId>com.google.auto.service</groupId>
<artifactId>auto-service</artifactId>
<version>1.0-rc7</version>
<scope>provided</scope>
</dependency>
public interface GreetingService {
String sayHello();
}
@Service
public class GreetingServiceImpl implements GreetingService {
@Override
public String sayHello() {
return "Hello, AutoService!";
}
}
@AutoService(GreetingService.class)
public class GreetingServiceAutoServiceProcessor extends AbstractProcessor {
@Override
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
return true;
}
}
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<annotationProcessorPaths>
<path>
<groupId>com.google.auto.service</groupId>
<artifactId>auto-service</artifactId>
<version>1.0-rc7</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
</plugins>
</build>
META-INF/services/com.example.GreetingService
com.example.GreetingServiceImpl