我一直在尝试将fluent-mysql依赖项添加到我的蒸气项目中,以便从该项目中查询单独的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'
我从蒸气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"])
]
)
在此先感谢您的帮助。这是我的第一个stackOverflow问题,非常抱歉。我正在运行vapor Toolbox 3.1.7
和Vapor framework 2.4.4
,并且同时安装了mysql
和cmysql
。
答案 0 :(得分:2)
您要使用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"]),
]
)
答案 1 :(得分:1)
出现这些错误的原因是因为Vapor 3不包含“ Droplet”,“ Resource”或“ ResourceRepresentable”类型。好消息是您已经成功安装了蒸气3依赖项,这是一个坏消息,要使用它们,您必须使蒸气3成为项目。好消息,蒸气3比蒸气2更出色。