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
| @Data public class User{ private String username; private String password; }
@ApplicationScoped public class UserService{ public String sayHello(User user){ return "say hello: " + user.getUserName() + " " + user.getPassword(); } }
@Path("/hello") public class ExampleResource{ @Inject UserService userService; @GET @Produces(MediaType.TEXT_PLAIN) public String hello(){ User user = new User(); user.setUsername("test"); user.setPassword("666"); return this.userService.sayHello(user); } }
|