我正在尝试连接两个数据源,MySQL并且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.example</groupId>
<artifactId>easy-notes</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>easy-notes</name>
<description>Demo project for Spring Boot</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.0.M7</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<neo4j-ogm.version>3.0.0</neo4j-ogm.version>
<spring-data-releasetrain.version>Kay-RELEASE</spring-data-releasetrain.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-neo4j</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-rest</artifactId>
</dependency>
<!-- -->
<dependency> …Run Code Online (Sandbox Code Playgroud) 我必须制作一个 jar 来点击 API 来获取人员详细信息列表,该列表基本上有四个字段:id、name、salary、department。
我正在使用 apache httpclient 执行 get 请求,该请求在点击 API 时为我提供了 httpentity。
httpentity提供了一个获取response内容的方法,但它返回的是inputstream。
在通过 inputreader 读取此输入流并将其打印出来时,我确认它为我提供了人员详细信息列表。
但我不知道如何将其转换为人员详细信息列表。
那是 PersonDetails 对象:-
public class PersonDetails {
private UUID id;
private String name;
private String department;
private Integer salary;
public UUID getId() {
return id;
}
public void setId(UUID id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getDepartment() {
return department;
}
public void setDepartment(String …Run Code Online (Sandbox Code Playgroud) 我正在尝试为我的配置存储库建立一个文件夹结构。
\nroot\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 serviceA\n\xe2\x94\x82 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 application-dev.properties\n\xe2\x94\x82 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 application-prod.properties\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 serviceB\n\xe2\x94\x82 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 application-dev.properties\n\xe2\x94\x82 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 application-prod.properties\nRun Code Online (Sandbox Code Playgroud)\n在我的配置服务器中,我有以下内容application.yml
server:\n port: 8081\nspring:\n application:\n name: cloud-config-server\n cloud:\n config:\n server:\n monitor:\n github:\n enabled: true\n gitee:\n enabled: true\n git:\n password: ${PASSWORD}\n username: ${USERNAME}\n uri: ${LINK_TO_CONFIG}\n default-label: master\n search-paths: serviceA, serviceB\nRun Code Online (Sandbox Code Playgroud)\n当运行服务器并请求时http://localhost:8081/serviceA/prod,http://localhost:8081/serviceB/prod我得到相同的结果
{\n "name":"serviceA",\n "profiles":[\n "prod"\n ],\n "label":null,\n "version":"9df32c9dbd11be65e892caf878ddc8d16906a849",\n "state":null,\n "propertySources":[\n {\n "name":"GITHUB_URI/springcloudconfigrepo/serviceB/application-prod.properties",\n "source":{\n "profile":"some-service-prod"\n }\n },\n {\n "name":"GITHUB_URI//springcloudconfigrepo/serviceA/application-prod.properties",\n "source":{\n "profile":"another-service-prod"\n }\n }\n ]\n}\nRun Code Online (Sandbox Code Playgroud)\n我的问题是,如何仅获取 serviceA (或 serviceB)的属性?
\n …我有一类Seller是extendslaravel的User模型,如下
namespace App;
class Seller extends User{
public function products(){
return $this->hasMany(Products::class);
}
}
Run Code Online (Sandbox Code Playgroud)
在ModelFactory.php我有以下代码
$factory->define(Transaction::class, function (Faker\Generator $faker) {
$seller = Seller::has('products')->get()->random();
$buyer = User::all()->except($seller->id)->random();
return [
'quantity' => $faker->numberBetween(0, 3),
'buyer_id' => $buyer->id,
'product_id' => $seller->products->random()->id
];
});
Run Code Online (Sandbox Code Playgroud)
我收到以下错误
找不到基本表或视图:1146表'tutorial.sellers'不存在(SQL:从
sellers存在的位置选择*(从。= 。products位置选择* ))sellersidproductsseller_id
的Product类是因为以下
namespace App;
use Illuminate\Database\Eloquent\Model;
class Product extends Model{
const AVAILABLE_PRODUCT = 'available';
const UNAVAILABLE_PRODUCT = 'unavailable';
protected …Run Code Online (Sandbox Code Playgroud)