当前位置: 首页 > news >正文

做网站软件流程门户型网站建设方案

做网站软件流程,门户型网站建设方案,网站群维护方案,营销推广网站1.Neo4j访问的两种方式 嵌入式数据库服务器模式(通过REST的访问) 它是由应用程序的性质(neo4j是独立服务器 还是和程序在一起),性能,监控和数据安全性来决定架构选择。 An embedded database(嵌入式数据库) 嵌入式Neo4j数据库…

1.Neo4j访问的两种方式

  • 嵌入式数据库
  • 服务器模式(通过REST的访问)

它是由应用程序的性质(neo4j是独立服务器 还是和程序在一起),性能,监控和数据安全性来决定架构选择。

An embedded database(嵌入式数据库)

嵌入式Neo4j数据库是性能的最佳选择。 通过指定数据存储的路径以编程方式访问嵌入式数据库。

我们选择嵌入式数据库出于以下原因:

  • 使用Java作为我们项目的编程语言时
  • 应用程序是独立的
  • 程序追求很高的性能

Neo4j Server(服务器模式)

Neo4j Server是相互操作性,安全性和监控的最佳选择。 实际上,REST接口允许所有现代平台和编程语言与它进行互操作。 此外,作为独立应用程序,它比嵌入式配置更安全(客户端中的潜在故障不会影响服务器),并且更易于监控。 如果我们选择使用这种模式,我们的应用程序将充当Neo4j服务器的客户端。要连接到Neo4j服务器,可以使用任何编程语言的REST 访问数据库。

2.Java客户端操作Neo4j

1…嵌入式模式

<dependency><groupId>org.neo4j</groupId><artifactId>neo4j</artifactId><version>4.0.1</version>
</dependency>
public class EmbeddedNeo4jAdd {private static final File databaseDirectory = new File( "target/graph.db" );public static void main(String[] args) {GraphDatabaseService graphDb = new GraphDatabaseFactory().newEmbeddedDatabase(databaseDirectory);System.out.println("Database Load!");Transaction tx = graphDb.beginTx();Node n1 = graphDb.createNode();n1.setProperty("name", "张三");n1.setProperty("character", "A");n1.setProperty("gender",1);n1.setProperty("money", 1101);n1.addLabel(new Label() {@Overridepublic String name() {return "Person";}});String cql = "CREATE (p:Person{name:'李四',character:'B',gender:1,money:21000})";graphDb.execute(cql);tx.success();tx.close();System.out.println("Database Shutdown!");graphDb.shutdown();}
}
public class EmbeddedNeo4jQueryAll {private static final File databaseDirectory = new File( "target/graph.db" );public static void main(String[] args) {GraphDatabaseService graphDb = new GraphDatabaseFactory().newEmbeddedDatabase(databaseDirectory);System.out.println("Database Load!");String cql = "MATCH (a:Person) where a.money < $money return a";Map<String, Object> paramerters = new HashMap<String, Object>();paramerters.put("money", 25000);Transaction tx = graphDb.beginTx();Result result = graphDb.execute(cql,paramerters);while (result.hasNext()) {Map<String, Object> row = result.next();for (String key : result.columns()) {Node nd = (Node) row.get(key);System.out.printf("%s = %s:%s%n", key,nd.getProperty("name"),nd.getProperty("money"));}}tx.success();tx.close();System.out.println("Database Shutdown!");graphDb.shutdown();}
}

2.服务器模式

<dependency><groupId>org.neo4j</groupId><artifactId>neo4j-ogm-bolt-driver</artifactId><version>3.2.12</version>
</dependency>
public class Neo4jServerMain {public static void main(String[] args) {Driver driver = GraphDatabase.driver( "bolt://127.0.0.1:7687", AuthTokens.basic( "neo4j", "123456" ) );Session session = driver.session();String cql = "MATCH (a:Person) WHERE a.money > $money " +"RETURN a.name AS name, a.money AS money order by a.money ";Result result = session.run( cql,5.3 SpringBoot 整合Neo4jparameters( "money", 1000 ) );while ( result.hasNext() ){Record record = result.next();System.out.println( record.get( "name" ).asString() + " " +record.get( "money" ).asDouble() );}session.close();driver.close();}
}
public class Neo4jServerMain2 {public static void main(String[] args) {Driver driver = GraphDatabase.driver( "bolt://127.0.0.1:7687", AuthTokens.basic( "neo4j", "123456" ) );Session session = driver.session();String cql = "MATCH p=shortestPath((person:Person {name:$startName})-[*]-(person2:Person {name:$endName} )) RETURN p";Result result = session.run( cql,parameters("startName","王启年","endName","九品射手燕小乙") );while ( result.hasNext() ){Record record = result.next();System.out.println(record);}session.close();driver.close();}
}

3.SpringBoot 整合Neo4j

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"><modelVersion>4.0.0</modelVersion><groupId>com.release</groupId><artifactId>neo4j-demo</artifactId><version>1.0-SNAPSHOT</version><properties><maven.compiler.source>11</maven.compiler.source><maven.compiler.target>11</maven.compiler.target><project.build.sourceEncoding>UTF-8</project.build.sourceEncoding></properties><parent><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-parent</artifactId><version>2.3.1.RELEASE</version></parent><dependencies><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-data-neo4j</artifactId></dependency><dependency><groupId>org.neo4j</groupId><artifactId>neo4j-ogm-bolt-driver</artifactId></dependency><dependency><groupId>org.projectlombok</groupId><artifactId>lombok</artifactId><version>1.18.4</version><scope>provided</scope></dependency></dependencies></project>
@NodeEntity
@Data
public class Person {@Id@GeneratedValueprivate Long id;@Property("cid")private int pid;@Propertyprivate String name;private String character;private double money;private int gender;private int age;private String description;@Relationship(type = "Friends", direction = Relationship.INCOMING)private Set<Person> relationPersons;
}
@Repository
public interface PersonRepository extends Neo4jRepository<Person, Long> {@Query("match(p:Person) where p.money>$money return p")List<Person> personList(@Param("money") double money);/*** 指定开始的名字 和 结束的名字 查询最短路径 限定深度为4以层包含4*/@Query("match p=shortestPath((person:Person{name:$startName})-[*1..4]- (person2:Person {name:$endName})) return p")List<Person> shortestPath(@Param("startName") String startName, @Param("endName") String endName);
}
@Service
public class Neo4jPersonService {@Autowiredprivate PersonRepository personRepository;public List<Person> personList(double money) {return personRepository.personList(money);}public Person save(Person person) {return personRepository.save(person);}public List<Person> shortestPath(String startName, String endName) {return personRepository.shortestPath(startName, endName);}
}
@SpringBootApplication
public class TestNeo4jBootApp {public static void main(String[] args) {ApplicationContext app = SpringApplication.run(TestNeo4jBootApp.class, args);Neo4jPersonService personService = app.getBean(Neo4jPersonService.class);System.out.println(personService);Person person = new Person();person.setName("庆帝");person.setAge(35);person.setCharacter("qingdi");person.setGender(0);person.setDescription("范闲的爹");person.setMoney(10000);Person save = personService.save(person);System.out.println("save:" + save);List<Person> peopleList = personService.personList(100);for (Person person1 : peopleList) {System.out.println("person1:" + person1);}}
}
http://www.sczhlp.com/news/75263/

相关文章:

  • 专业企业网站搭建服务安陆建设局网站
  • 网站同步更新到新浪微博域名查ip
  • 餐饮网站欣赏扫二维码进入个人的购物网站如何做
  • 网站编辑教程开发一个网页具体流程
  • 寿光建设网站wordpress禁用字体
  • 网站 用户体验做网站友情链接都写什么
  • 大数据做网站免费网页建设
  • 鹤壁建设网站推广公司电话福建福州罗源建设局网站
  • 网页做得好的网站设计logo网站生成器
  • 春蕾科技 网站建设wordpress清理插件哪个好
  • 线性回归模型的核心数学表达式
  • 使用PM2工具部署Vue.js应用于服务器
  • Java理解while循环的使用
  • 手机网站解析地址教育培训机构网站
  • 网站运营与推广南宁做网站费用
  • 网站上用的字体扫码进入网站 怎么做
  • 定制设计的网站微网站和手机网站的区别
  • 关于二分算法
  • 网站要实名认证吗电脑网络服务在哪里
  • 免费人脉推广网站建设优化两千字
  • 重庆做兼职哪个网站自学网站开发多少时间
  • 做自媒体网站建网站需要什么要求
  • 珠海新盈科技 网站建设服务器可以吧网站做跳转吗
  • 优秀的网站建设解决方案精美企业网站
  • 公司网站开发怎么做建设路84号 网站备案
  • 询价网站哪个好湖北工程建设信息网站
  • Create Custom Endpoint in Directus
  • 做美容美发的网站有哪些怎样用腾讯云做网站
  • 合肥的网站建设州南皮做网站
  • access做网站数据库烟台网站建设加企汇互联专业