我正在使用 Node.js v14.13.0。
app.js文件:
import database from './database';
database();
Run Code Online (Sandbox Code Playgroud)
数据库/index.js文件:
import mongoose from 'mongoose';
export default connect = async () => {
try {
await mongoose.connect('...', { });
} catch (error) {}
};
Run Code Online (Sandbox Code Playgroud)
在package.json我添加了"type": "module".
运行应用程序后,我收到以下错误:
错误 [ERR_UNSUPPORTED_DIR_IMPORT]:目录导入 '/Users/xx/Desktop/Projects/node-starter/src/database' 不支持解析从 /Users/xx/Desktop/Projects/node-starter/src/app 导入的 ES 模块。 js
当我尝试导航到端点时,出现以下错误
类型定义错误:[简单类型,类org.hibernate.proxy.pojo.bytebuddy.ByteBuddyInterceptor];嵌套的异常是com.fasterxml.jackson.databind.exc.InvalidDefinitionException:未为类org.hibernate.proxy.pojo.bytebuddy.ByteBuddyInterceptor找到序列化器,也未找到创建BeanSerializer的属性(为避免异常,请禁用SerializationFeature.FAIL_ON_EMPTY_BEANS)
我检查了所有模型,所有属性都有getter和setter。所以有什么问题 ?
我可以通过添加来解决此问题,spring.jackson.serialization.fail-on-empty-beans=false但我认为这只是隐藏异常的一种解决方法。
编辑
Product 模型:
@Entity
public class Product {
private int id;
private String name;
private String photo;
private double price;
private int quantity;
private Double rating;
private Provider provider;
private String description;
private List<Category> categories = new ArrayList<>();
private List<Photo> photos = new ArrayList<>();
// Getters & Setters
}
Run Code Online (Sandbox Code Playgroud)
PagedResponse 类:
public class PagedResponse<T> {
private List<T> content;
private int page;
private int size;
private long totalElements;
private int totalPages;
private boolean last; …Run Code Online (Sandbox Code Playgroud) 我下载并安装了 MongoDb 的最后一个版本 4.0.2,并设置了正确的路径变量。
当我想使用mongod命令启动 mondoDb 服务时,出现以下错误:
initAndListen 中的异常:NonExistentPath:未找到数据目录 C:\data\db\。,正在终止
我知道我应该创建缺少的目录,但是该目录会在以下路径中自动创建: C:\Program Files\MongoDB\Server\4.0
我检查了 mongod.cfg 文件并且已经设置了正确的路径:dbPath: C:\Program Files\MongoDB\Server\4.0\data
现在如何告诉 mongo 查找他认为在正确路径中丢失的文件夹?
我正在尝试使用brew 在 macOS Big Sur 上安装 MongoDB 服务器,我正在关注 mongo 官方网站上的文档。
我运行以下命令:
brew tap mongodb/brew
Run Code Online (Sandbox Code Playgroud)
之后,我运行:
brew install mongodb-community@4.4
Run Code Online (Sandbox Code Playgroud)
但我收到以下错误:
错误:未找到类似名称的公式。
错误:没有名称为“mongosh”的可用公式(mongodb/brew/mongodb-community 的依赖项)。
它已从 mongodb/brew 迁移到 homebrew/core。
我正在尝试将电影添加到MySQL数据库,这是我的数据库模式:
Movie(id, name)
Genre(id, name)
Movie_genre(id_movie, id_genre)
Run Code Online (Sandbox Code Playgroud)
这是我的模型类:
Movie.ts
public class Movie {
private Short id;
private String name;
private List<MovieGenre> movieGenres;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id", nullable = false)
public Short getId() {
return id;
}
public void setId(Short id) {
this.id = id;
}
@Column(name = "name", nullable = false, length = 100)
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
@OneToMany(mappedBy = "movie")
public List<MovieGenre> getMovieGenres() { …Run Code Online (Sandbox Code Playgroud) 我正在使用 Spring security 来保护我的 REST 服务中的一些端点。
这是安全配置类:
@Configuration
@EnableWebSecurity
@EnableGlobalMethodSecurity(securedEnabled = true, jsr250Enabled = true, prePostEnabled = true)
public class SecurityConfig extends WebSecurityConfigurerAdapter {
// Other methods
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.cors()
.and()
.csrf()
.disable()
.exceptionHandling()
.authenticationEntryPoint(this.jwtAuthenticationEntryPoint)
.and()
.sessionManagement()
.sessionCreationPolicy(SessionCreationPolicy.STATELESS)
.and()
.authorizeRequests()
.antMatchers("/",
"/favicon.ico",
"/**/*.png",
"/**/*.gif",
"/**/*.svg",
"/**/*.jpg",
"/**/*.html",
"/**/*.css",
"/**/*.js")
.permitAll()
.antMatchers(HttpMethod.POST, "/api/auth/**")
.permitAll()
.anyRequest()
.authenticated();
// Add our custom JWT security filter
http.addFilterBefore(jwtAuthenticationFilter(), UsernamePasswordAuthenticationFilter.class);
}
}
Run Code Online (Sandbox Code Playgroud)
正如您所看到的,我通过使用以下命令获得了对/api/auth/signup和/api/auth/signin的完全访问权限:.antMatchers(HttpMethod.POST, "/api/auth/**").permitAll() …
使用 npm install 成功安装依赖项后,运行服务器时出现以下错误:
Schema validation failed with the following errors: Data path ".builders['browser']" should have required property 'class'.
Run Code Online (Sandbox Code Playgroud)
搜索了一段时间后,我认为问题出在"@angular-builders/custom-webpack".
该项目运行良好,但我不小心将其删除并再次克隆它,然后出现错误。
这是开发依赖项:
"devDependencies": {
"@angular-builders/custom-webpack": "latest",
"@angular-builders/dev-server": "latest",
"@angular-devkit/build-angular": "~0.13.6",
"@angular/cli": "~7.3.6",
"@angular/compiler-cli": "~7.2.10",
"@angular/language-service": "~7.2.10",
"@biesbjerg/ngx-translate-extract": "~2.3.4",
"@types/jasmine": "~3.3.12",
"@types/jasminewd2": "~2.0.3",
"@types/node": "~11.11.4",
"codelyzer": "~5.0.0-beta.1",
"dotenv": "latest",
"jasmine-core": "~3.3.0",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~4.0.1",
"karma-chrome-launcher": "~2.2.0",
"karma-cli": "~2.0.0",
"karma-coverage-istanbul-reporter": "~2.0.0",
"karma-jasmine": "~2.0.1",
"karma-jasmine-html-reporter": "~1.4.0",
"protractor": "~5.4.2",
"rxjs-tslint": "~0.1.7",
"ts-node": "~8.0.3",
"tslint": "~5.14.0",
"typescript": "~3.2.0",
"webpack": "~4.29.6"
}
Run Code Online (Sandbox Code Playgroud)
这是我的 …
我正在使用:graphql-spring-boot 和 graphql-java-tools 来实现。
电影.graphqls
type Movie {
id: Short
name: String
poster: String
releaseDate: String
runtime: String
storyline: String
rated: String
rating: String
inserted: String
}
type Query {
movies: [Movie]
movie(id: ID!): Movie
}
Run Code Online (Sandbox Code Playgroud)
电影模型
@Entity
public class Movie {
private Short id;
private String name;
private String poster;
private Date releaseDate;
private Time runtime;
private String storyline;
private String rated;
private double rating;
private Timestamp inserted;
}
Run Code Online (Sandbox Code Playgroud)
正如你所看到的,我与其他模型没有任何关系。最后是实现GraphQLQueryResolver 的
类
@Component
public class Query implements GraphQLQueryResolver …Run Code Online (Sandbox Code Playgroud) 我正在使用Android Studio 3.2版,并且具有12GB的ram和双显卡(NVIDIA和INTEL)。
我已经安装了HAXM,还强制emulator.exe和qemu-system-x86_64.exe与NVIDIA一起使用。
但是仿真器仍然非常慢
我有以下对象
const object = {
id: "1",
name: "a",
children: [
{
id: "2",
name: "b",
children: [
{
id: "3",
name: "c"
}
]
},
{
id: "4",
name: "d"
}
]
};
Run Code Online (Sandbox Code Playgroud)
我需要一个接受对象和最后一个孩子的 id 并返回路径的函数,例如,以下调用:getPath(object, '3');应返回[{id: 1}, {id: 2}, {id: 3}]。
我创建了该函数,但我只能访问第一个父级。
function getPath(model, id, parent) {
if (model == null) {
return;
}
if (model.id === id) {
console.log(model.id, parent.id)
}
if (model.children) {
model.children.forEach(child => getPath(child, id, model));
}
}
Run Code Online (Sandbox Code Playgroud)
PS:物体的深度未知。
spring-boot ×4
java ×3
spring ×3
mongodb ×2
spring-mvc ×2
android ×1
angular ×1
database ×1
es6-modules ×1
graphql ×1
graphql-java ×1
hibernate ×1
homebrew ×1
javascript ×1
macos ×1
node.js ×1
object ×1
recursion ×1
webpack ×1