我使用 OData4J (JPAProducer) 创建了一个非常基本的生产者示例现在我可以在浏览器正常上看到有关模式的信息。但是 excel 2013 数据连接向导显示错误。我用http://services.odata.org/V3/OData/OData.svc/尝试了 Excel, 效果很好。我究竟做错了什么。
任何帮助将不胜感激。
public static JPAProducer createProducer() {
Map properties = new HashMap();
properties.put(PersistenceUnitProperties.NON_JTA_DATASOURCE, DatabaseUtil.getDataSource());
javax.persistence.EntityManagerFactory factory = Persistence.createEntityManagerFactory("persistentunit",
properties);
JPAProducer producer = new JPAProducer(factory, "", 50);
return producer;
}
public static void startService() {
DefaultODataProducerProvider.setInstance(createProducer());
hostODataServer("http://localhost:8887/JPAProducerExample.svc/");
}
public static void main(String[] args) {
startService();
}
private static void hostODataServer(String baseUri) {
ODataServer server = null;
try {
server = startODataServer(baseUri);
} catch (Exception e) {
System.out.print(e.getLocalizedMessage());
}
}
private static ODataServer startODataServer(String baseUri) {
return createODataServer(baseUri).start();
}
private static ODataServer createODataServer(String baseUri) {
return new ODataJerseyServer(baseUri, ODataApplication.class, RootApplication.class);
}