gpt4 book ai didi

mysql - 将 FluentMySQL 与 vapor 3 结合使用

转载 作者:可可西里 更新时间:2023-11-01 00:55:07 24 4
gpt4 key购买 nike

几天来,我一直在尝试将 fluent-mysql 依赖项添加到我的 vapor 项目中,以便从项目中查询我单独的 mysql 数据库。但是我似乎总是会遇到某种错误,例如当我尝试 vapor update它永远不会完成。 (过去我已经离开了几个小时),我也试过swift package update但那有同样的错误。我现在处于 vapor update 的地步有效,但是我仍然遇到两个错误 'mysql/udf_registration_types.h' file not found with <angled> include; use "quotes" instead

Could not build Objective-C module 'CMySQL'

我从 vapor 网页模板中唯一改变的是 package.swift现在是这样的:

import PackageDescription

let package = Package(
name: "iPadLocator",
products: [
.library(name: "App", targets: ["App"]),
.executable(name: "Run", targets: ["Run"])
],
dependencies: [
.package(url: "https://github.com/vapor/vapor.git", .upToNextMajor(from: "2.2.0")),
.package(url: "https://github.com/vapor/leaf-provider.git", .upToNextMajor(from: "1.1.0")),
.package(url: "https://github.com/vapor/fluent-mysql.git", .upToNextMajor(from: "2.0.0"))

],
targets: [
.target(
name: "App",
dependencies: ["Vapor", "LeafProvider", "MySQLDriver"],
exclude: ["Config", "Database", "Public", "Resources"]
),
.target(name: "Run", dependencies: ["App"]),
.testTarget(name: "AppTests", dependencies: ["App", "Testing"])
]
)

提前感谢您的任何帮助。这是我的第一个 stackOverflow 问题,很抱歉,如果它很糟糕。我在跑vapor Toolbox 3.1.7Vapor framework 2.4.4 , 我都有 mysqlcmysql已安装并且是最新的。

最佳答案

您想使用 Vapor 2 还是 Vapor 3? (忽略工具箱的版本)。如果您想要 Vapor 2,那么您拥有的是正确的 - 您只需将依赖项从 MySQLDriver 更改为 MySQLProvider

如果你想要 Vapor 3,那么你需要将所有依赖项更改为类似

// swift-tools-version:4.0
import PackageDescription

let package = Package(
name: "TILApp",
dependencies: [
// 💧 A server-side Swift web framework.
.package(url: "https://github.com/vapor/vapor.git", from: "3.0.0"),
.package(url: "https://github.com/vapor/fluent-mysql.git", from: "3.0.0"),
.package(url: "https://github.com/vapor/leaf.git", from: "3.0.0-rc"),
],
targets: [
.target(name: "App", dependencies: ["FluentMySQL", "Vapor", "Leaf"]),
.target(name: "Run", dependencies: ["App"]),
.testTarget(name: "AppTests", dependencies: ["App"]),
]
)

关于mysql - 将 FluentMySQL 与 vapor 3 结合使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51609899/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com