a.添加ureport依赖(根据需要添加其他依赖)com.bstek.ureport ureport2-console2.1.5
b.注册服务bean,访问ureport
@Configuration
@ImportResource("reportcontext.xml")
public class UreportConfig {
@Bean
public ServletRegistrationBean builderUreport(){
return new ServletRegistrationBean(new UReportServlet(),"/ureport
@Component
public class UreportDataSource implements BuildinDatasource {
private static final Logger log = LoggerFactory.getLogger(UreportDataSource.class);
@Autowired
private DataSource dataSource;
@Override
public String name() {
return "内置数据源";
}
@Override
public Connection getConnection() {
try {
return dataSource.getConnection();
} catch (SQLException e) {
e.printStackTrace();
log.error("报表数据源初始化错误");
return null;
}
}
}
f.报表设计完成保存后,可以通过
http://host[:port][/context-path]/ureport/preview?_u=file:报表名称 预览



