以前、
修正しました。
過去Entryは
目次
参考サイト
Githubへの
* core/wicketstuff-restannotations-parent at master · wicketstuff/core
1. pomに 以下の 記述を 追加する
<dependency> <groupId>org.wicketstuff</groupId> <artifactId>wicketstuff-restannotations</artifactId> <version>7.3.0</version> </dependency> <dependency> <groupId>org.wicketstuff</groupId> <artifactId>wicketstuff-restannotations-json</artifactId> <version>7.3.0</version> </dependency>
2. AbstractRestResourceの 継承クラスを 作成する
GsonRestResourceが
継承クラスを、
GsonかJacksonどちらの
Gsonを
public FestivalApis() { super(new JsonWebSerialDeserial(new GsonObjectSerialDeserial())); }
- 削除した
記述
import org.wicketstuff.rest.resource.gson.GsonRestResource;
- 変更したRestサービスAPI
package xyz.monotalk.web.apis; import java.util.List; import javax.persistence.EntityManager; import javax.persistence.EntityManagerFactory; import javax.persistence.Persistence; import org.wicketstuff.rest.annotations.MethodMapping; import org.wicketstuff.rest.contenthandling.json.objserialdeserial.JacksonObjectSerialDeserial; import org.wicketstuff.rest.contenthandling.json.webserialdeserial.JsonWebSerialDeserial; import org.wicketstuff.rest.resource.AbstractRestResource; import xyz.monotalk.models.entity.Festival; public class FestivalApis extends AbstractRestResource<JsonWebSerialDeserial> { public FestivalApis() { super(new JsonWebSerialDeserial(new JacksonObjectSerialDeserial())); } private static final long serialVersionUID = -7863247209549049518L; @MethodMapping("/festivals") @SuppressWarnings("unchecked") public List<Festival> getAllFestivals() { EntityManagerFactory emf = Persistence.createEntityManagerFactory("POfDM_Local"); EntityManager em = null; List<Festival> festivals = null; try { em = emf.createEntityManager(); festivals = (List<Festival>) em.createNamedQuery("findAllFestivals").getResultList(); } finally { if (em != null) { em.close(); } } return festivals; } }
上記の
以上です。
コメント