小编jem*_*thi的帖子

找不到在docker compose环境中运行的节点js app的模块

我很抱歉我的新手问题,但是我正在度过这个错误的可怕日子,我有一个Express应用程序,我试图在docker compose中运行它.我用过这个Dockerfile:

FROM mhart/alpine-node
RUN mkdir -p /usr/src/app
RUN chmod -R 777 /usr/src/app
WORKDIR /usr/src/app
RUN npm install node-gyp -g
RUN npm install nodemon -g
ENV NODE_ENV development
EXPOSE 3000
Run Code Online (Sandbox Code Playgroud)

这部分我的docker-compose文件:

backend:
    mem_limit: 100m
    build:
      context: .
      dockerfile: dockerfiles/node/Dockerfile
    command: npm start
    depends_on:
      - mongo
      - elasticsearch
    volumes:
      - ./backend/:/usr/src/app
    ports:
      - 3000:3000
    links:
      - "mongo:mongo"
      - "elasticsearch:elasticsearch"
Run Code Online (Sandbox Code Playgroud)

当我做docker-compose时,我收到这个错误:

backend_1        | npm info it worked if it ends with ok
backend_1        | npm info using npm@3.10.10
backend_1        | npm info …
Run Code Online (Sandbox Code Playgroud)

node.js npm docker docker-compose

11
推荐指数
4
解决办法
3万
查看次数

请求方法'OPTIONS'不受支持 - Spring Boot Application

我在服务器端使用Spring Boot,在客户端使用Angularjs,我使用Filter配置Spring Boot应用程序CORS,它适用于GET,POST方法,但是,当我尝试使用$ http模块发送PUT请求时,我得到了这个在我的浏览器控制台:

注意:url = http:// localhost:8080/localbusinessusers/[object%20Object]

选项url (匿名函数)@ angular.js:11442sendReq @ angular.js:11235serverRequest @ angular.js:10945processQueue @ angular.js:15552(匿名函数)@ angular.js:15568Scope.$ eval @ angular.js:16820Scope. $ digest @ angular.js:16636Scope.$ apply @ angular.js:16928done @ angular.js:11266completeRequest @ angular.js:11464requestLoaded @ angular.js:11405 app.html:1 XMLHttpRequest无法加载 网址.预检的响应具有无效的HTTP状态代码405 angular.js:11442 XHR加载失败:PUT" url ".

我在Spring Boot控制台上得到了这个:

2016-03-08 23:19:51.212 WARN 27044 --- [XNIO-2 task-2] osweb.servlet.PageNotFound:不支持请求方法'OPTIONS'

我的CORS 过滤器:

package com.datcom.fouras;

import …
Run Code Online (Sandbox Code Playgroud)

javascript spring cors angularjs spring-boot

5
推荐指数
1
解决办法
8192
查看次数

转到Vuejs 2的特定路线

我是VueJS的新手,我正在使用VueJS 2 Webpack模板.如果登录成功,我试图从登录组件重定向到主组件,我尝试了很多东西,但我仍然遇到错误.这是我的路线:

const router = new VueRouter({
  mode: 'history',
  routes: [{
    'name': 'home',
    path: '/',
    component: require('./components/Home.vue'),
    beforeEnter: (to, from, next) => {
      if (!localStorage.getItem('user')) {
        next('/login')
      }
    }
  }, {
    'name': 'profile',
    path: '/profile',
    component: require('./components/Profile.vue'),
    beforeEnter: (to, from, next) => {
      if (!localStorage.getItem('user')) {
        next('/login')
      }
    }
  }, {
    'name': 'login',
    path: '/login',
    component: require('./components/Login.vue')
  }, {
    'name': 'new',
    path: '/new',
    component: require('./components/New.vue'),
    beforeEnter: (to, from, next) => {
      if (!localStorage.getItem('user')) {
        next('/login')
      }
    }
  }, { …
Run Code Online (Sandbox Code Playgroud)

javascript vue.js vue-router vue-component vuejs2

5
推荐指数
1
解决办法
3764
查看次数

如何在Mongoose.js中检查更新前/更新后挂钩中的修改字段

我需要知道修改的字段,或者一个特定领域是在修改 更新挂钩的猫鼬架构。我尝试了以下操作,但仍然无法弄清楚:

schema.post('update', function (doc) {
    //check modified fields or if the name field was modified and then update doc
});
Run Code Online (Sandbox Code Playgroud)

我知道也许有一个方法isModified就像在 保存中一样,但是我不知道如何使用更新挂钩。任何建议将不胜感激。

javascript mongoose mongodb node.js mongoose-schema

5
推荐指数
2
解决办法
4040
查看次数

在Spring Boot应用程序中进行Spring Data Elastic搜索

我有一个Spring Boot应用程序,我想在其中使用独立的Elastic search 2.2.0(不是嵌入式服务器),我想使用Spring Data Elastic search,那么Spring Data支持的Elastic search版本是什么以及如何配置它连接到在localhost:9200中运行的elasticsearch实例吗?

实际上,我尝试将以下选项添加到我的application.properties文件中:

spring.data.elasticsearch.repositories.enabled=true
spring.data.elasticsearch.cluster-nodes=localhost:9200
Run Code Online (Sandbox Code Playgroud)

然后,我创建了这个配置类:

@Configuration
public class ElasticConfig {

    @Bean
    public ElasticsearchOperations elasticsearchTemplate() {
        return new ElasticsearchTemplate(client());
    }

    @Bean
    public Client client() {
        TransportClient client = new TransportClient();
        TransportAddress address = new InetSocketTransportAddress(
                "localhost",9200);
        client.addTransportAddress(address);
        return client;
    }
}
Run Code Online (Sandbox Code Playgroud)

我得到这个堆栈跟踪:

2016-04-28 00:03:52.246 INFO 25613 --- [restartedMain] org.elasticsearch.plugins:[Aardwolf]已加载[],网站[] 2016-04-28 00:04:01.356 INFO 25613 --- [ restartedMain] org.elasticsearch.client.transport:[Aardwolf]无法获取[#transport#-1] [fathi-HP-Pavilion-g6-Notebook-PC] [inet [localhost / 127.0.0.1:9200]]的节点信息],正在断开连接...

org.elasticsearch.transport.ReceiveTimeoutTransportException:[] [inet [localhost / 127.0.0.1:9200]] [cluster:monitor / nodes / info] request_id …

java spring elasticsearch spring-boot spring-data-elasticsearch

2
推荐指数
1
解决办法
1万
查看次数

无法捕获从 Angular 4 中的子组件发出的事件

我很抱歉我的新手问题,我正在尝试使用@Output EventEmitter. 我无法在我的父组件中捕获事件。

子组件

@Component({
  selector: 'app-new-attachment',
  templateUrl: './new-attachment.component.html',
  styleUrls: ['./new-attachment.component.css']
})
class NewAttachmentComponent {
  @Input('attachment') attachment: any;
  @Output() doneEditingAttachment:EventEmitter<boolean> = new EventEmitter<boolean>();

  submit() {
    console.log('done editing child');
    this.doneEditingAttachment.emit(true);
  }
}
Run Code Online (Sandbox Code Playgroud)

父组件

@Component({
  selector: 'app-new-article',
  templateUrl: './new-article.component.html',
  styleUrls: ['./new-article.component.css']
})
class NewArticleComponent {
   newAttachment: any = {};
   doneEditingAttachment($event) {
     console.log('done editing parent ', $event);
   }
}
Run Code Online (Sandbox Code Playgroud)

我希望有

完成编辑孩子

而一个

完成编辑父项

但我只完成了编辑孩子

javascript typescript angular2-components angular

2
推荐指数
1
解决办法
2967
查看次数