如何在spring mvc和hibernate中进行推送通知

时间:2015-06-20 05:31:26

标签: java hibernate spring-mvc google-cloud-messaging

我在spring mvc和hibernate中有一个小的web应用程序。

在这个Web服务中通过推送通知将数据库转换成数据会自动进入android设备。

怎么做推送通知?

restful controller

@Controller
@RequestMapping("/json")
public class JsonData 
{

    @Autowired
    private AdminService adminService;

    @GET
    @RequestMapping(value="/jsonEnglishWord")
    @Produces(MediaType.APPLICATION_JSON)
    public @ResponseBody List<English_Word> getAllWord() {

        return new ArrayList<English_Word>(adminService.getAllWord());

    }

    @GET
    @RequestMapping(value="/jsonGujaratiWord")
    @Produces(MediaType.APPLICATION_JSON)
    public @ResponseBody List<Gujarati_Word> getallGujarati_Words(){

        return new ArrayList<Gujarati_Word>(adminService.getAllGujaratiword());
    }

数据库模型

@Entity
@Table(name="English_Word")
public class English_Word {

    @Id
    @GeneratedValue(strategy=GenerationType.AUTO)
    private int word_id;

    private String word_name;

    @Lob
    private String word_explain;

    @Temporal(TemporalType.DATE)
    private Date word_date;

    public int getWord_id() {
        return word_id;
    }

    public void setWord_id(int word_id) {
        this.word_id = word_id;
    }

    public String getWord_name() {
        return word_name;
    }

    public void setWord_name(String word_name) {
        this.word_name = word_name;
    }

    public String getWord_explain() {
        return word_explain;
    }

    public void setWord_explain(String word_explain) {
        this.word_explain = word_explain;
    }

    public Date getWord_date() {
        return word_date;
    }

    public void setWord_date(Date word_date) {
        this.word_date = word_date;
    }

}

1 个答案:

答案 0 :(得分:0)

请参阅以下链接。它帮助到我。检查java代码。首先在谷歌上创建应用

http://javapapers.com/android/google-cloud-messaging-gcm-for-android-and-push-notifications/