我正在尝试在我的 spring-boot 文件中添加一个环境变量application.properties
。我知道如何在非 spring-boot 项目上正常添加它,但我找不到添加环境变量的字段,这就是我看到的:
这是我的 application.properties 文件,这可能会有所帮助。
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql://localhost:3306/FTHLDB
spring.datasource.username=root
spring.datasource.password=${MYSQL_PASS}
spring.jpa.show-sql=true
spring.jpa.hibernate.ddl-auto=update
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL5Dialect
spring.jpa.properties.hibernate.format_sql=true
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用get
rust 向 url 发出请求,每次运行此项目时都会收到此错误,而我的其他 rust 项目工作正常。这是我的cargo.toml
文件。
[package]
name = "api_req"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
serde = { version = "1.0", features = ["derive"] }
reqwest = { version = "0.11", features = ["json"] }
tokio = { version = "1", features = ["full"]}
Run Code Online (Sandbox Code Playgroud)
这是我尝试构建/运行代码时得到的输出。
error: linking with `x86_64-w64-mingw32-gcc` failed: exit code: 1
|
= note: "x86_64-w64-mingw32-gcc" "-fno-use-linker-plugin" "-Wl,--dynamicbase" "-Wl,--disable-auto-image-base" "-m64" "-Wl,--high-entropy-va" "C:\\Users\\sahil\\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\self-contained\\crt2.o" "C:\\Users\\sahil\\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\rsbegin.o" "C:\\Users\\sahil\\CLionProjects\\coc-rs\\target\\debug\\deps\\coc_rs-6b97e9afad26cc80.1ax3t6bk8kjti15h.rcgu.o" …
Run Code Online (Sandbox Code Playgroud) 我有一些异步函数
async fn get_player(name: String, i: Instant) -> Option<Player> {
// some code here that returns a player structs
}
Run Code Online (Sandbox Code Playgroud)
在我的主函数中,我想在循环中同时运行上述函数,该函数大约需要 1 秒才能完成,并且我需要运行它至少 50 次,因此我想让它同时运行该函数 50 次。在我的主函数中,我有一个lazy_static自定义Client
结构,该结构不应创建多次。
主功能
#[tokio::main]
async fn main() {
client.init().await;
println!("start");
for i in 0..10 {
println!("{}", i);
let now = Instant::now();
tokio::spawn(async move {
client.get_player("jay".to_string(), now).await;
});
}
loop {}
}
Run Code Online (Sandbox Code Playgroud)
我传递即时的原因是因为在我的 get_player 函数中我有一个 println!() 只打印执行时间。
上面的 main 方法每个函数调用大约需要 500ms,但是下面的代码只需要 100ms。
#[tokio::main]
async fn maain(){
client.init().await;
for i in 0..10 {
let now …
Run Code Online (Sandbox Code Playgroud)