jsonrpc4j and Spring
package hello;
import com.googlecode.jsonrpc4j.spring.AutoJsonRpcServiceExporter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.jdbc.datasource.DriverManagerDataSource;
import org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping;
import javax.sql.DataSource;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;
@SpringBootApplication
public class Application {
@Bean
public static UserService userService(){
return new UserServiceImpl();
}
@Bean
public static MarginService marginService(){
return new MarginServiceImpl();
}
@Bean
public static AutoJsonRpcServiceExporter autoJsonRpcServiceExporter(){
return new AutoJsonRpcServiceExporter();
}
@Bean
public DriverManagerDataSource dataSource(){
DriverManagerDataSource dataSource = new DriverManagerDataSource();
dataSource.setDriverClassName("com.mysql.jdbc.Driver");
dataSource.setUrl("jdbc:mysql://127.0.0.1:3306/btcchina_mk");
dataSource.setUsername("root");
dataSource.setPassword("root");
return dataSource;
}
@Bean
public JdbcTemplate jdbcTemplate(DataSource dataSource){
JdbcTemplate template = new JdbcTemplate();
template.setDataSource(dataSource);
return template;
}
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}