小编Sad*_*tun的帖子

node.js TypeError [ERR_INVALID_PROTOCOL]:不支持协议“http:”。预期“https:

下面给出 Node.js 代码,我尝试使用 https 作为项目所需但出现错误

类型错误 [ERR_INVALID_PROTOCOL]:不支持协议“http:”。预期为“https:”

const express = require("express");
var https = require("https");


const app = express();


app.get("/", function(req, res) {

    const url = "http://api.openweathermap.org/data/2.5/weather?q=Gwalior&appid=4b01458a2b74d57ff37f136f382ac4d5&units=metric";

    https.get(url, function(response) {
        console.log(response.statusCode)
    });
    res.send("Server is Up and Running");
})



app.listen(3000, function() {
    console.log("Server is running on port 3000.");
})
Run Code Online (Sandbox Code Playgroud)

完整的错误堆栈跟踪:

TypeError [ERR_INVALID_PROTOCOL]: Protocol "http:" not supported. Expected "https:"
    at new ClientRequest (_http_client.js:151:11)
    at request (https.js:316:10)
    at Object.get (https.js:320:15)
    at C:\Users\Public\Documents\WeatherProject\app.js:12:10
    at Layer.handle [as handle_request] (C:\Users\Public\Documents\WeatherProject\node_modules\express\lib\router\layer.js:95:5)
    at next (C:\Users\Public\Documents\WeatherProject\node_modules\express\lib\router\route.js:137:13)
    at Route.dispatch (C:\Users\Public\Documents\WeatherProject\node_modules\express\lib\router\route.js:112:3) …
Run Code Online (Sandbox Code Playgroud)

node.js express node-modules

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

Spring boot项目如何保存DB用户名和密码

当我尝试为我的 Java 项目创建安全的生产环境时,我应该在哪里保存数据库用户名、密码和 url,以保持安全,目前我正在使用应用程序属性来保存数据库凭据,请建议一些良好且安全的方法来保存数据库凭据。

应用程序属性

# This should be used only for credentials and other local-only config.
spring.datasource.url = jdbc:postgresql://localhost/database
spring.datasource.username = root
spring.datasource.password = root@123
Run Code Online (Sandbox Code Playgroud)

我应该在哪里保存安全和生产 Spring boot 项目

java security spring spring-boot application.properties

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

Node.js 安装错误“该应用程序仅在 Windows 8.1、Windows Server 2012 R2 或更高版本上受支持”

当我尝试从 node.js 安装最新的 LTS 版本:14.15.3(包括 npm 6.14.9)时,出现以下错误

系统信息:Windows 7旗舰版

错误信息:尝试在 Windows 7 操作系统上安装时出现“该应用程序仅在 Windows 8.1、Windows Server 2012 R2 或更高版本上受支持”错误

在此输入图像描述

user-interface node.js web

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

如何在Java中联合列出<Date> list1和List <Date> list2?

  public class ArrayOfArrayList {
public static void main(String[] args) {
    List<Date> dateList1 = new ArrayList<Date>();
    List<Date> dateList2 = new ArrayList<Date>();
    Calendar cal = new GregorianCalendar();
    for(int i = 0; i < 5; i++) {
        Date d1 = new Date();
        cal.setTime(d1);
        cal.add(Calendar.DATE, i);
        dateList1.add(cal.getTime());
    }
    System.out.println("   *************** Date List 1st ****************");
    for(Date date1 : dateList1) {
        System.out.println("1stList"+date1);
    }
    System.out.println("   *************** Date List 1st ****************");

    for(int i = 2; i < 8; i++) {
        Date d2 = new Date();
        cal.setTime(d2);
        cal.add(Calendar.DATE, i); …
Run Code Online (Sandbox Code Playgroud)

java union arraylist duplicates

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

Arraylist无法删除重复的字符串

public static void main(String[] args) {
       List<String> list = new ArrayList();
       list.add("AA");list.add("Aw");list.add("Aw");list.add("AA");
       list.add("AA");list.add("A45");list.add("AA");
       list.add("Aal");list.add("Af");list.add("An");

       System.out.println(list);

       for(int i=0;i<list.size();i++){
          if(list.get(i).equals("AA")){
             list.remove(i);
          }
       }

       System.out.println(list);
}
Run Code Online (Sandbox Code Playgroud)

我目前正在尝试删除ArrayList中具有值的所有元素"AA",但是,它只删除其中的一些而不是全部.任何人都可以向我解释我做错了什么?

arraylist中的元素:

[AA, Aw, Aw, AA, AA, A45, AA, Aal, Af, An]
Run Code Online (Sandbox Code Playgroud)

我试图删除所有具有值的字符串后输出"AA".

[Aw, Aw, AA, A45, Aal, Af, An]
Run Code Online (Sandbox Code Playgroud)

为什么还在AA输出列表中?

java collections arraylist

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

Spring:通过字段、CrudRepository扩展接口表达的不满足的依赖关系

我已经扩展CrudRepository<ClassName, Id>了用户定义的接口,但是在尝试使用注入时,@Autowired我收到以下错误:

创建名称为“helloController”的 bean:通过字段“danCorePrivateRepository”表达的依赖关系不满足;嵌套异常是 org.springframework.beans.factory.NoSuchBeanDefinitionException:没有“com.sgcorp.repository.DanCorePrivateRepository”类型的合格 bean 可用:预计至少有 1 个有资格作为自动装配候选者的 bean。

HelloController.java

@RestController
@RequestMapping("/hello")
public class HelloController {
    @Autowired
    private DanCorePrivateRepository danCorePrivateRepository;

    @RequestMapping(value = "/service", method= RequestMethod.GET)
    public String selectService(){  
        String result = "<html>";   
        result += "<div>"+danCorePrivateRepository.findAll()+"</div>";
        return result+ "</html>";
    }
}
Run Code Online (Sandbox Code Playgroud)

DanCorePrivateRepository.java(用户定义接口)

public interface DanCorePrivateRepository extends CrudRepository<DanaModel, String> {

}
Run Code Online (Sandbox Code Playgroud)

请建议为什么它不正确@Autowired?

注意:在其他一些项目中它正在运行。

java spring crud autowired spring-data-jpa

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