小编Sar*_*ala的帖子

一个带Java/Socket的简单Http服务器?

我目前正在创建一个返回静态页面的小型HTTP服务器<p>Hello!</p>...我尝试使用Java的套接字:

  public static void main(String[] args) throws Exception {

        // création de la socket
        int port = 1989;
        ServerSocket serverSocket = new ServerSocket(port);
        System.err.println("Serveur lancé sur le port : " + port);

        // repeatedly wait for connections, and process
        while (true) {

            // on reste bloqué sur l'attente d'une demande client
            Socket clientSocket = serverSocket.accept();
            System.err.println("Nouveau client connecté");

            // on ouvre un flux de converation

           BufferedReader in = new BufferedReader(
                           new InputStreamReader(clientSocket.getInputStream())
                          ); 
            PrintWriter out = new PrintWriter( …
Run Code Online (Sandbox Code Playgroud)

java sockets http

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

在本机中使用地图时出错

我想在我的本机应用中使用地图.所以我安装了airbnb的react-native-maps,但是当我尝试构建应用程序时,它总是显示此错误"Could not find method compileOnly() for arguments [com.facebook.react:react-native:+] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.",我已经设置了构建gradle,设置gradle和MainApllication.有人可以帮我吗? 我的Build.Gradle

dependencies {
    compile(project(':react-native-maps')){
        exclude group: 'com.google.android.gms', module: 'play-services-base'
        exclude group: 'com.google.android.gms', module: 'play-services-maps'
    }
    compile 'com.google.android.gms:play-services-base:10.0.1'
    compile 'com.google.android.gms:play-services-maps:10.0.1'
    compile fileTree(dir: "libs", include: ["*.jar"])
    compile "com.android.support:appcompat-v7:23.0.1"
    compile "com.facebook.react:react-native:+"  // From node_modules
}
Run Code Online (Sandbox Code Playgroud)

我的Setting.Gradle

rootProject.name = 'MapDemo'
include ':react-native-maps'
project(':react-native-maps').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-maps/lib/android')
include ':app'
Run Code Online (Sandbox Code Playgroud)

我的MainApplication.Java

import com.airbnb.android.react.maps.MapsPackage;
 @Override
    protected List<ReactPackage> getPackages() {
      return Arrays.<ReactPackage>asList(
          new MainReactPackage(),
           new MapsPackage()
      );
    }
Run Code Online (Sandbox Code Playgroud)

android google-maps reactjs react-native

6
推荐指数
1
解决办法
2151
查看次数

Sequelize targetKey 不起作用

我正在尝试使用sequelize关联两个模型“Note”和“Resource”。但是,targetKey 没有按预期工作。

注意模态

module.exports = function(sequelize, DataTypes) {
  return sequelize.define('note', {
    NoteID: {
      type: DataTypes.INTEGER(11),
      allowNull: false,
      primaryKey: true,
      autoIncrement: true
    },
    Title: {
      type: DataTypes.STRING(50),
      allowNull: true
    },
    Note: {
      type: DataTypes.STRING(500),
      allowNull: false
    },
    CreatedBy: {
      type: DataTypes.INTEGER(11),
      allowNull: false,
      references: {
        model: 'resource',
        key: 'ResourceID'
      }
    },
    UpdatedBy: {
      type: DataTypes.INTEGER(11),
      allowNull: true,
      references: {
        model: 'resource',
        key: 'ResourceID'
      }
    }
  }, {
    tableName: 'note'
  });
};
Run Code Online (Sandbox Code Playgroud)

资源模式

module.exports = function(sequelize, DataTypes) {
  return sequelize.define('resource', …
Run Code Online (Sandbox Code Playgroud)

associations node.js sequelize.js

6
推荐指数
1
解决办法
5510
查看次数

构建 Docker 镜像并使用 github 标签名称进行标记

我已经创建了一个关于创建存储库标签的 GitHub 操作。我成功地构建了 Docker 映像并将其推送到 AWS,但是我不知道如何使用与 GitHub 标签相同的名称来标记该映像。下面是我的 git 工作流程文件

name: Build Docker Image and Push to AWS ECR
on:
  push:
    tags:
    - '*'


jobs:

  build:

     runs-on: ubuntu-latest

     steps:
         - name: Checkout
           uses: actions/checkout@v1

         - name: Configure AWS credentials
           uses: aws-actions/configure-aws-credentials@v1
           with:
               aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
               aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
               aws-region: us-west-2

         - name: Login to Amazon ECR
           id: login-ecr
           uses: aws-actions/amazon-ecr-login@v1

         - name: Build, tag, and push image to Amazon ECR
           id: build-image
           env:
               ECR_REGISTRY: ${{ secrets.AWS_REGISTRY }}
               ECR_REPOSITORY: …
Run Code Online (Sandbox Code Playgroud)

git-tag docker docker-image github-actions

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

PHPMailer IsHTML(true) 不工作

我正在尝试从 PHPMailer 发送电子邮件。一切正常,但问题是即使在编写$mail->IsHTML(true);. 下面是我发送电子邮件的代码。

    $mail = new PHPMailer(); 
    $mail->IsSMTP();
    $mail->SMTPDebug = 1;
    $mail->SMTPAuth = true; 
    $mail->SMTPSecure = EMAIL_COMPOSE_SECURE; 
    $mail->Host = EMAIL_COMPOSE_SMTP_HOST;  
    $mail->Port = EMAIL_COMPOSE_PORT;
    $mail->Username = EMAIL_COMPOSE_OUTGOING_USERNAME;
    $mail->Password = EMAIL_COMPOSE_OUTGOING_PASSWORD;
    $mail->SetFrom(EMAIL_COMPOSE_INCOMING_USERNAME);
    $mail->Subject =$subject;

    $mail->Body = $message;
    $mail->IsHTML(true);
    $mail->AddAddress($email_to);
    if(!$mail->Send()){
        echo "Mailer Error: " . $mail->ErrorInfo;
    }
    else{
      echo "Message has been sent";
    }
Run Code Online (Sandbox Code Playgroud)

还有一件事我要提到,在我的应用程序文本编辑器中用于编写电子邮件是 ckeditor。这会导致任何问题吗?请帮忙。

php email phpmailer

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

如何阻止这种线程?

我有一个具有此代码的线程

while(!this.isInterrupted()) {
    try {
        socket = server.accept();
    }
    catch(IOException e) {
        continue;
    }
}
Run Code Online (Sandbox Code Playgroud)

当我从某个地方调用中断方法时,它只有在检查条件时才会停止执行.如果程序在server.accept()语句中怎么办?在任何套接字发出任何请求之前,它不会停止.我希望当我调用中断方法时,应该立即停止.有没有解决这个问题的方法.

java multithreading

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