Spring Data REST + GemFire + AngularJS Integration
2015-09-12 11:09
671 查看
This tutorial explains the integration between Spring Data REST, GemFire and AngularJS frameworks. We are going to develop a REST service which returns the JSON response and that will be accessed by the AngularJS web page.
Tools Required
We’ve developed this tutorial by using the following tools:
JDK 1.6.
Tomcat 7.
Maven 3.
GemFire 7.0.1.
AngularJS
2. Project Structure
Here is the project structure used for this tutorial.
Spring REST - GemFire - Eclipse Project Directory
3. Business Domain
Message is the persistence object used for storing the data in GemFire’s in-memory storage. We are using only this entity for this tutorial. If you look at the below code, the entity imports the org.springframework.data.gemfire.mapping.Region which is equivalent to the table in the relational database. This Region class used as the segment in in-memory and allocate the storage for the data.
Message.java
package net.javabeat.springdata.data;
import org.springframework.data.annotation.Id;
import org.springframework.data.annotation.PersistenceConstructor;
import org.springframework.data.gemfire.mapping.Region;
@Region(“messages”)
public class Message {
@Id
private String messageId;
private String message;
public Message() {
}
@PersistenceConstructor
public Message(String id, String message) {
this.messageId = id;
this.message = message;
}
public String getMessageId() {
return messageId;
}
public void setMessageId(String messageId) {
this.messageId = messageId;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
}
4. Spring Data Repository
It’s the repositories that enable the CRUD operations against the business domain. In our previous tutorial I have explained theSpring Dataand how the repositories used for the CRUD operations.
MessageReposirory.java
package net.javabeat.springdata.repo;
import net.javabeat.springdata.data.Message;
import org.springframework.data.repository.CrudRepository;
import org.springframework.data.rest.core.annotation.RepositoryRestResource;
@RepositoryRestResource(collectionResourceRel=”messages”,path=”messages”)
public interface MessageRepository extends CrudRepository
Tools Required
We’ve developed this tutorial by using the following tools:
JDK 1.6.
Tomcat 7.
Maven 3.
GemFire 7.0.1.
AngularJS
2. Project Structure
Here is the project structure used for this tutorial.
Spring REST - GemFire - Eclipse Project Directory
3. Business Domain
Message is the persistence object used for storing the data in GemFire’s in-memory storage. We are using only this entity for this tutorial. If you look at the below code, the entity imports the org.springframework.data.gemfire.mapping.Region which is equivalent to the table in the relational database. This Region class used as the segment in in-memory and allocate the storage for the data.
Message.java
package net.javabeat.springdata.data;
import org.springframework.data.annotation.Id;
import org.springframework.data.annotation.PersistenceConstructor;
import org.springframework.data.gemfire.mapping.Region;
@Region(“messages”)
public class Message {
@Id
private String messageId;
private String message;
public Message() {
}
@PersistenceConstructor
public Message(String id, String message) {
this.messageId = id;
this.message = message;
}
public String getMessageId() {
return messageId;
}
public void setMessageId(String messageId) {
this.messageId = messageId;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
}
4. Spring Data Repository
It’s the repositories that enable the CRUD operations against the business domain. In our previous tutorial I have explained theSpring Dataand how the repositories used for the CRUD operations.
MessageReposirory.java
package net.javabeat.springdata.repo;
import net.javabeat.springdata.data.Message;
import org.springframework.data.repository.CrudRepository;
import org.springframework.data.rest.core.annotation.RepositoryRestResource;
@RepositoryRestResource(collectionResourceRel=”messages”,path=”messages”)
public interface MessageRepository extends CrudRepository
相关文章推荐
- angularJS web应用SEO
- 初学angularJS之controller作用域
- 初学angularJS之$scope用法
- AngularJs 表单提交数据不能以key-value 形式传到后台的解决方案
- AngularJS之directive
- Angularjs ng-table的使用(可以加button)以及angularjs学习资料
- AngularJS进阶(五)Angular实现下拉菜单多选
- AngularJS进阶(五)Angular实现下拉菜单多选
- AngularJS进阶(四)ANGULAR.JS实现下拉菜单单选
- AngularJS进阶(四)ANGULAR.JS实现下拉菜单单选
- AngularJS进阶(三)HTML:让表单、文本框只读,不可编辑的方法
- AngularJS进阶(三)HTML:让表单、文本框只读,不可编辑的方法
- 走进AngularJs之过滤器(filter)
- 理解angularjs的作用域
- 前端javascript框架之AngularJS学习笔记
- angularjs的双向绑定详解
- angularJs1.x <三、ng-bind>
- angularJs1.x<二、控制器Controller>
- angularJs<一、数据绑定>
- ANGULARJS 动态编译添加到dom中