使用fluentmysql和vapor 3

tyky79it  于 2021-06-20  发布在  Mysql
关注(0)|答案(2)|浏览(364)

几天来,我一直在尝试将fluentmysql依赖性添加到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 web模板所做的唯一更改是 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"])
    ]
)

提前感谢您的帮助。这是我的第一个问题,很抱歉,如果它是可怕的。我在跑步 vapor Toolbox 3.1.7 以及 Vapor framework 2.4.4 ,我两者都有 mysql 以及 cmysql 安装并更新。

xtupzzrd

xtupzzrd1#

你想用蒸汽2还是蒸汽3(忽略工具箱的版本)。如果您想要Vapor2,那么您所拥有的是正确的-您只需要将依赖项从 MySQLDriverMySQLProvider .
如果您想要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"]),
    ]
)
kkih6yb8

kkih6yb82#

出现这些错误的原因是vapor 3不包含“droplet”“resource”或“resourcerepresentable”类型。好消息是您成功安装了Vapor3依赖项,坏消息是为了使用它们,您必须使您的项目Vapor3成为一个独立的依赖项。好消息,蒸汽3比蒸汽2性能更好。

相关问题