package com.example.service; public interface GreetingService { void sayHello(); } <dependency> <groupId>com.google.auto.service</groupId> <artifactId>auto-service</artifactId> <version>1.0-rc4</version> </dependency> package com.example.service; import com.google.auto.service.AutoService; @AutoService(GreetingService.class) public class DefaultGreetingService implements GreetingService { @Override public void sayHello() { System.out.println("Hello, AutoService!"); } } <build> <plugins> <plugin> <groupId>org.bsc.maven</groupId> <artifactId>maven-processor-plugin</artifactId> <version>2.2.4</version> <executions> <execution> <goals> <goal>process</goal> </goals> <configuration> <processors> <processor>com.google.auto.service.AutoServiceProcessor</processor> </processors> </configuration> </execution> </executions> <dependencies> <dependency> <groupId>com.google.auto.service</groupId> <artifactId>auto-service</artifactId> <version>1.0-rc4</version> </dependency> </dependencies> </plugin> </plugins> </build>


上一篇:
下一篇:
切换中文