我有这样的应用程序结构:
react-client
server
docker-compose.yaml
Run Code Online (Sandbox Code Playgroud)
golang 服务器通常在 docker 中启动。现在我想在那里运行反应。这是我的 docker 文件react-client
FROM node:alpine
WORKDIR /app/react
COPY package.json /app/react
COPY package-lock.json /app/react
COPY . /app/react
EXPOSE 3001
RUN npm i
CMD ["npm", "run", "start"]
Run Code Online (Sandbox Code Playgroud)
我的 docker-compose 文件:
version: '3'
services:
postgres:
image: postgres:12
restart: always
ports:
- '5432:5432'
volumes:
- ./db_data:/var/lib/postgresql/data
- ./server/scripts/init.sql:/docker-entrypoint-initdb.d/create_tables.sql
env_file:
- ./server/config/.env
healthcheck:
test: [ "CMD", "pg_isready", "-q", "-d", "devdb", "-U","postgres" ]
timeout: 45s
interval: 10s
retries: 10
redis:
image: redis:6.2
volumes:
- /var/run/docker.sock:/var/run/docker.sock
ports:
- 6379:6379 …Run Code Online (Sandbox Code Playgroud) 我有一堂课:
template <typename T>
class List {
private:
struct pointNode {
T data;
pointNode* next;
pointNode* prev;
pointNode() :data(0), next(nullptr), prev(nullptr) {}
pointNode(T n_data) : data(n_data), next(nullptr), prev(nullptr) {}
const T& getValue() {
return this->data;
}
};
pointNode* head;
pointNode* tail;
public:
class Iterator {
//friend class List;
using Iterator_type = List<T>::pointNode;
public:
Iterator(Iterator_type* rNode) {
current_node = rNode;
}
bool operator !=(const Iterator& pNode) {
return this->current_node != pNode.current_node;
}
T const get_value() {
return this->current_node->data;
}
private:
Iterator_type* …Run Code Online (Sandbox Code Playgroud) 我正在尝试制作第一个 spring boot 和 gradle 项目。我从 spring 初始化 io 下载了一个 gradle 项目。
构建.gradle
plugins {
id 'org.springframework.boot' version '2.5.5'
id 'io.spring.dependency-management' version '1.0.11.RELEASE'
id 'java'
id 'war'
}
group = 'com.example'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '1.8'
repositories {
mavenCentral()
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-security'
implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.thymeleaf.extras:thymeleaf-extras-springsecurity5'
runtimeOnly 'org.postgresql:postgresql'
providedRuntime 'org.springframework.boot:spring-boot-starter-tomcat'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'org.springframework.security:spring-security-test'
}
test {
useJUnitPlatform()
}
Run Code Online (Sandbox Code Playgroud)
设置.gradle
rootProject.name = 'TestForMVC'
Run Code Online (Sandbox Code Playgroud)
然后我尝试执行生成的 main:
package com.example.TestForMVC;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public …Run Code Online (Sandbox Code Playgroud) 我想尝试编写一个模板包装器来检查一个类是否具有成员函数。为此,有必要使用 std::declval
template<typename T>
struct has_member<T, void_t<decltype(std::declval<T>().push_back())>>:std::true_type{};
Run Code Online (Sandbox Code Playgroud)
如我所见,declval 的实现应该是这样的:
template<typename T>
T&& declval() noexcept;
Run Code Online (Sandbox Code Playgroud)
实际上,这可能是一个奇怪的问题,但是为什么 declval 没有 return 语句?
如果我理解正确,它应该将右值返回到调用的位置:
template<typename T>
struct has_member<T, void_t<decltype(T&&.push_back())>>:std::true_type{};
Run Code Online (Sandbox Code Playgroud)
但是我们没有在 implementation 中使用 return 。也许是因为我们没有函数体?我想了解为什么这是可能的。我很乐意帮忙
我正在阅读通配符,但我有点困惑。我真的不明白为什么 ifPresent 方法需要? super T.
public void ifPresent(Consumer<? super T> consumer)
为什么不只是 T 工作?
我已经阅读了有关 PECS 的内容,并且很清楚它是如何用于类方法的,例如,但是为什么它会出现在界面中,我很乐意提供帮助。
我正在阅读最初的 Rust 指南。那里表明不可能从函数返回对字符串的引用。
fn dangle() -> &String { // dangle returns a reference to a String
let s = String::from("hello"); // s is a new String
&s // we return a reference to the String, s
} // Here, s goes out of scope, and is dropped. Its memory goes away.
// Danger!
Run Code Online (Sandbox Code Playgroud)
但我对下一章的示例感到困惑,其中切片的链接是从函数返回的:
fn first_word(s: &String) -> &str {
let bytes = s.as_bytes();
for (i, &item) in bytes.iter().enumerate() {
if item == b' ' {
return &s[0..i];
}
} …Run Code Online (Sandbox Code Playgroud)