使用JDBI的java.lang.NoSuchMethodError

时间:2018-09-03 21:31:01

标签: dropwizard jdbi

public class MyApplication extends Application<MyConfiguration> {

final static Logger LOG = Logger.getLogger(MyApplication.class);
public static void main(final String[] args) throws Exception {
    new MyApplication().run(args);
}

@Override
public String getName() {
    return "PFed";
}

@Override
public void initialize(final Bootstrap<MyConfiguration> bootstrap) {
    // TODO: application initialization
    bootstrap.addBundle(new DBIExceptionsBundle());
}

@Override
public void run(final MyConfiguration configuration,
                final Environment environment) {
    // TODO: implement application

    final DBIFactory factory = new DBIFactory();
    final DBI jdbi = factory.build(environment, configuration.getDataSourceFactory(), "postgresql");

    UserDAO userDAO = jdbi.onDemand(UserDAO.class);
    userDAO.findNameById(1);


    UserResource userResource = new UserResource(new UserService(userDAO));

    environment.jersey().register(userResource);
}

在findNameById处出现以下错误。

java.lang.NoSuchMethodError:java.lang.Object.findNameById(I)Ljava / lang / String;         在org.skife.jdbi.v2.sqlobject.CloseInternalDoNotUseThisClass $$ EnhancerByCGLIB $$ a0e63670.CGLIB $ findNameById $ 5()

}

public interface UserDAO {

@SqlQuery("select userId  from user where id = :email")
User isEmailAndUsernameUnique(@Bind("email") String email);

@SqlQuery("select name from something where id = :id")
String findNameById(@Bind("id") int id);

}

0 个答案:

没有答案