我想基于 Amazon Linux AMI 2 映像在 EC2 实例上安装 PostgreSQL 11。在帖子、SO 问题和找到最新的 Postgresl yum 存储库之后,我尝试了:
sudo yum install https://download.postgresql.org/pub/repos/yum/reporpms/EL-8-x86_64/pgdg-redhat-repo-latest.noarch.rpm
Run Code Online (Sandbox Code Playgroud)
我收到此错误:
--> Processing Dependency: /etc/redhat-release for package: pgdg-redhat-repo-42.0-4.noarch
--> Finished Dependency Resolution
Error: Package: pgdg-redhat-repo-42.0-4.noarch (/pgdg-centos11-11-2.noarch)
Requires: /etc/redhat-release
Run Code Online (Sandbox Code Playgroud)
我被卡住了..有没有一种干净的方法来克服这个问题?
我有两个实体:产品和类别。一个产品可以属于一个类别,因此两个实体之间存在 OneToMany 关系:
/**
* @ORM\Entity()
*/
class Category
{
/**
* @ORM\Id()
* @ORM\GeneratedValue()
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=255)
*/
private $name;
/**
* @ORM\OneToMany(targetEntity="App\Entity\Product", mappedBy="category")
*/
private $products;
public function __construct()
{
$this->products = new ArrayCollection();
}
public function getProducts(): Collection
{
return $this->products;
}
public function addProduct(Product $product): self
{
if (!$this->products->contains($product)) {
$this->products[] = $product;
$product->setCategory($this);
}
return $this;
}
public function removeProduct(Product $product): self
{
if ($this->products->contains($product)) {
$this->products->removeElement($product);
$product->setCategory(null);
} …Run Code Online (Sandbox Code Playgroud) 我有一个 Kafka 实例正在运行(本地,在 Docker 中),并且我使用sarama 包在 Go 中创建了一个生产者。
由于我想在我的主题上使用 Kafka Streams,生产者必须在消息中嵌入时间戳,否则我会收到这个丑陋的错误消息:
org.apache.kafka.streams.errors.StreamsException:输入记录ConsumerRecord(主题=crawler_events,分区= 0,偏移= 0,CreateTime = -1,序列化键大小= -1,序列化值大小= 187,标题= RecordHeaders( headers = []、isReadOnly = false)、key = null、value = {XXX}) 具有无效(负)时间戳。可能是因为使用 0.10 之前版本的生产者客户端将此记录写入 Kafka,而没有嵌入时间戳,或者因为输入主题是在 Kafka 集群升级到 0.10+ 之前创建的。使用不同的 TimestampExtractor 来处理此数据。
以下是在我的 Go 程序中发送消息的代码部分:
// Init a connection to the Kafka host,
// create the producer,
// and count successes and errors in delivery
func (c *kafkaClient) init() {
config := sarama.NewConfig()
config.Producer.Return.Successes = true
c.config = *config
var err error …Run Code Online (Sandbox Code Playgroud) 我正在使用 GitLab CI/CD,并将流程的秘密变量存储在自定义 CI/CD 变量中,如此处所述。
它一开始很小,只有几个变量,使用 UI 来定义变量就可以了。但现在,我的项目变得更大了,我最终得到了几十个变量,乘以相当数量的环境。此时,在 UI 中管理它们就变得很乏味:
我想做的,在我看来更容易管理,是将环境的所有变量放在一个文件中:
API_TOKEN_VALUE=xxxx
APP_EMAIL_SENDER=xxx
AWS_ACCESS_KEY_ID=xxx
AWS_ACCESS_KEY=xxx
...
Run Code Online (Sandbox Code Playgroud)
然后将此单个文件存储为VAR_FILE“文件”类型的唯一 CI/CD 变量:

我的问题是,如果我这样做,我如何访问这些变量并使gitlab-ci.yml它们可供作业使用?
我使用以下方法创建了一个新的Symfony 3.4项目:
composer create-project symfony/skeleton my-project
Run Code Online (Sandbox Code Playgroud)
之后我添加了以下组件:
composer require twig
composer require annotations
composer require maker
Run Code Online (Sandbox Code Playgroud)
并创建了一个控制器:
php bin/console make:controller
Run Code Online (Sandbox Code Playgroud)
我添加了一个"合法"路线的动作.这是DefaultController:
<?php
namespace App\Controller;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
class DefaultController extends Controller
{
/**
* @Route("/", name="homepage")
*/
public function index()
{
return $this->render('index.html.twig', [
'controller_name' => 'DefaultController',
]);
}
/**
* @Route("/legal", name="legal")
*/
public function legal()
{
return $this->render('legal.html.twig', []);
}
}
Run Code Online (Sandbox Code Playgroud)
文件config/routes.yaml:
#index:
# path: /
# defaults: { _controller: 'App\Controller\DefaultController::index' }
Run Code Online (Sandbox Code Playgroud)
和config/routes/annotations.yaml:
controllers:
resource: ../../src/Controller/
type: …Run Code Online (Sandbox Code Playgroud) 我正在 Symfony2 中处理一个遗留项目,其中实体的映射没有正确定义,但我不想接触它们......
我得到了一个具有多个 ManyToOne 关系的实体,但没有在这些关联上定义级联持久性。而且关联的实体也有关系,等等(项目挺大的)……
所以,当我需要向数据库写入一个新实体时,我通常使用合并来避免持久化所有相关实体:
$myObject = new Object();
...
$em->merge($myObject);
$em->flush();
Run Code Online (Sandbox Code Playgroud)
但这一次,我需要获取插入对象的 id。这个 id 是由 Doctrine 自动生成的(我也不想改变它)。
我知道通过坚持,我可以做到:
$em->persist($object);
$em->flush();
$id = $object->getId();
Run Code Online (Sandbox Code Playgroud)
但是我该怎么做合并呢?显然这行不通:
$em->merge($object);
$em->flush();
$id = $object->getId(); // $id is null...
Run Code Online (Sandbox Code Playgroud)
谢谢。
symfony ×3
doctrine ×2
apache-kafka ×1
doctrine-orm ×1
gitlab ×1
gitlab-ci ×1
go ×1
php ×1
postgresql ×1
sarama ×1
secret-key ×1
symfony-3.4 ×1
yum ×1