会员可以在此提问,百战程序员老师有问必答
对大家有帮助的问答会被标记为“推荐”
看完课程过来浏览一下别人提的问题,会帮你学得更全面
截止目前,同学们一共提了 132850个问题

"C:\Program Files\Java\jdk1.8.0_211\bin\java.exe" "-javaagent:E:\software\idea\ideasoft\IntelliJ IDEA 2019.3.2\lib\idea_rt.jar=51820:E:\software\idea\ideasoft\IntelliJ IDEA 2019.3.2\bin" -Dfile.encoding=UTF-8 -classpath "C:\Program Files\Java\jdk1.8.0_211\jre\lib\charsets.jar;C:\Program Files\Java\jdk1.8.0_211\jre\lib\deploy.jar;C:\Program Files\Java\jdk1.8.0_211\jre\lib\ext\access-bridge-64.jar;C:\Program Files\Java\jdk1.8.0_211\jre\lib\ext\cldrdata.jar;C:\Program Files\Java\jdk1.8.0_211\jre\lib\ext\dnsns.jar;C:\Program Files\Java\jdk1.8.0_211\jre\lib\ext\jaccess.jar;C:\Program Files\Java\jdk1.8.0_211\jre\lib\ext\jfxrt.jar;C:\Program Files\Java\jdk1.8.0_211\jre\lib\ext\localedata.jar;C:\Program Files\Java\jdk1.8.0_211\jre\lib\ext\nashorn.jar;C:\Program Files\Java\jdk1.8.0_211\jre\lib\ext\sunec.jar;C:\Program Files\Java\jdk1.8.0_211\jre\lib\ext\sunjce_provider.jar;C:\Program Files\Java\jdk1.8.0_211\jre\lib\ext\sunmscapi.jar;C:\Program Files\Java\jdk1.8.0_211\jre\lib\ext\sunpkcs11.jar;C:\Program Files\Java\jdk1.8.0_211\jre\lib\ext\zipfs.jar;C:\Program Files\Java\jdk1.8.0_211\jre\lib\javaws.jar;C:\Program Files\Java\jdk1.8.0_211\jre\lib\jce.jar;C:\Program Files\Java\jdk1.8.0_211\jre\lib\jfr.jar;C:\Program Files\Java\jdk1.8.0_211\jre\lib\jfxswt.jar;C:\Program Files\Java\jdk1.8.0_211\jre\lib\jsse.jar;C:\Program Files\Java\jdk1.8.0_211\jre\lib\management-agent.jar;C:\Program Files\Java\jdk1.8.0_211\jre\lib\plugin.jar;C:\Program Files\Java\jdk1.8.0_211\jre\lib\resources.jar;C:\Program Files\Java\jdk1.8.0_211\jre\lib\rt.jar;C:\IdeaProjects\springbootdemo1\target\classes;C:\Users\wjf\.m2\repository\org\springframework\boot\spring-boot-starter-web\2.2.0.RELEASE\spring-boot-starter-web-2.2.0.RELEASE.jar;C:\Users\wjf\.m2\repository\org\springframework\boot\spring-boot-starter\2.2.0.RELEASE\spring-boot-starter-2.2.0.RELEASE.jar;C:\Users\wjf\.m2\repository\org\springframework\boot\spring-boot\2.2.0.RELEASE\spring-boot-2.2.0.RELEASE.jar;C:\Users\wjf\.m2\repository\org\springframework\boot\spring-boot-autoconfigure\2.2.0.RELEASE\spring-boot-autoconfigure-2.2.0.RELEASE.jar;C:\Users\wjf\.m2\repository\org\springframework\boot\spring-boot-starter-logging\2.2.0.RELEASE\spring-boot-starter-logging-2.2.0.RELEASE.jar;C:\Users\wjf\.m2\repository\ch\qos\logback\logback-classic\1.2.3\logback-classic-1.2.3.jar;C:\Users\wjf\.m2\repository\ch\qos\logback\logback-core\1.2.3\logback-core-1.2.3.jar;C:\Users\wjf\.m2\repository\org\slf4j\slf4j-api\1.7.28\slf4j-api-1.7.28.jar;C:\Users\wjf\.m2\repository\org\apache\logging\log4j\log4j-to-slf4j\2.12.1\log4j-to-slf4j-2.12.1.jar;C:\Users\wjf\.m2\repository\org\apache\logging\log4j\log4j-api\2.12.1\log4j-api-2.12.1.jar;C:\Users\wjf\.m2\repository\org\slf4j\jul-to-slf4j\1.7.28\jul-to-slf4j-1.7.28.jar;C:\Users\wjf\.m2\repository\jakarta\annotation\jakarta.annotation-api\1.3.5\jakarta.annotation-api-1.3.5.jar;C:\Users\wjf\.m2\repository\org\springframework\spring-core\5.2.0.RELEASE\spring-core-5.2.0.RELEASE.jar;C:\Users\wjf\.m2\repository\org\springframework\spring-jcl\5.2.0.RELEASE\spring-jcl-5.2.0.RELEASE.jar;C:\Users\wjf\.m2\repository\org\yaml\snakeyaml\1.25\snakeyaml-1.25.jar;C:\Users\wjf\.m2\repository\org\springframework\boot\spring-boot-starter-json\2.2.0.RELEASE\spring-boot-starter-json-2.2.0.RELEASE.jar;C:\Users\wjf\.m2\repository\com\fasterxml\jackson\core\jackson-databind\2.10.0\jackson-databind-2.10.0.jar;C:\Users\wjf\.m2\repository\com\fasterxml\jackson\core\jackson-annotations\2.10.0\jackson-annotations-2.10.0.jar;C:\Users\wjf\.m2\repository\com\fasterxml\jackson\core\jackson-core\2.10.0\jackson-core-2.10.0.jar;C:\Users\wjf\.m2\repository\com\fasterxml\jackson\datatype\jackson-datatype-jdk8\2.10.0\jackson-datatype-jdk8-2.10.0.jar;C:\Users\wjf\.m2\repository\com\fasterxml\jackson\datatype\jackson-datatype-jsr310\2.10.0\jackson-datatype-jsr310-2.10.0.jar;C:\Users\wjf\.m2\repository\com\fasterxml\jackson\module\jackson-module-parameter-names\2.10.0\jackson-module-parameter-names-2.10.0.jar;C:\Users\wjf\.m2\repository\org\springframework\boot\spring-boot-starter-tomcat\2.2.0.RELEASE\spring-boot-starter-tomcat-2.2.0.RELEASE.jar;C:\Users\wjf\.m2\repository\org\apache\tomcat\embed\tomcat-embed-core\9.0.27\tomcat-embed-core-9.0.27.jar;C:\Users\wjf\.m2\repository\org\apache\tomcat\embed\tomcat-embed-el\9.0.27\tomcat-embed-el-9.0.27.jar;C:\Users\wjf\.m2\repository\org\apache\tomcat\embed\tomcat-embed-websocket\9.0.27\tomcat-embed-websocket-9.0.27.jar;C:\Users\wjf\.m2\repository\org\springframework\boot\spring-boot-starter-validation\2.2.0.RELEASE\spring-boot-starter-validation-2.2.0.RELEASE.jar;C:\Users\wjf\.m2\repository\jakarta\validation\jakarta.validation-api\2.0.1\jakarta.validation-api-2.0.1.jar;C:\Users\wjf\.m2\repository\org\hibernate\validator\hibernate-validator\6.0.17.Final\hibernate-validator-6.0.17.Final.jar;C:\Users\wjf\.m2\repository\org\jboss\logging\jboss-logging\3.4.1.Final\jboss-logging-3.4.1.Final.jar;C:\Users\wjf\.m2\repository\com\fasterxml\classmate\1.5.0\classmate-1.5.0.jar;C:\Users\wjf\.m2\repository\org\springframework\spring-web\5.2.0.RELEASE\spring-web-5.2.0.RELEASE.jar;C:\Users\wjf\.m2\repository\org\springframework\spring-beans\5.2.0.RELEASE\spring-beans-5.2.0.RELEASE.jar;C:\Users\wjf\.m2\repository\org\springframework\spring-webmvc\5.2.0.RELEASE\spring-webmvc-5.2.0.RELEASE.jar;C:\Users\wjf\.m2\repository\org\springframework\spring-aop\5.2.0.RELEASE\spring-aop-5.2.0.RELEASE.jar;C:\Users\wjf\.m2\repository\org\springframework\spring-context\5.2.0.RELEASE\spring-context-5.2.0.RELEASE.jar;C:\Users\wjf\.m2\repository\org\springframework\spring-expression\5.2.0.RELEASE\spring-expression-5.2.0.RELEASE.jar" com.wjf.SpringBootHelloWorldApplication

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v2.2.0.RELEASE)

2020-02-11 13:17:46.305  INFO 14808 --- [           main] com.wjf.SpringBootHelloWorldApplication  : Starting SpringBootHelloWorldApplication on DESKTOP-GNB6ND7 with PID 14808 (C:\IdeaProjects\springbootdemo1\target\classes started by wjf in C:\IdeaProjects\springbootdemo)
2020-02-11 13:17:46.305  INFO 14808 --- [           main] com.wjf.SpringBootHelloWorldApplication  : No active profile set, falling back to default profiles: default
2020-02-11 13:17:46.495  WARN 14808 --- [           main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.ApplicationContextException: Unable to start web server; nested exception is org.springframework.context.ApplicationContextException: Unable to start ServletWebServerApplicationContext due to missing ServletWebServerFactory bean.
2020-02-11 13:17:46.639 ERROR 14808 --- [           main] o.s.boot.SpringApplication               : Application run failed

org.springframework.context.ApplicationContextException: Unable to start web server; nested exception is org.springframework.context.ApplicationContextException: Unable to start ServletWebServerApplicationContext due to missing ServletWebServerFactory bean.
	at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:156) ~[spring-boot-2.2.0.RELEASE.jar:2.2.0.RELEASE]
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:544) ~[spring-context-5.2.0.RELEASE.jar:5.2.0.RELEASE]
	at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:141) ~[spring-boot-2.2.0.RELEASE.jar:2.2.0.RELEASE]
	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:747) [spring-boot-2.2.0.RELEASE.jar:2.2.0.RELEASE]
	at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397) [spring-boot-2.2.0.RELEASE.jar:2.2.0.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:315) [spring-boot-2.2.0.RELEASE.jar:2.2.0.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226) [spring-boot-2.2.0.RELEASE.jar:2.2.0.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1215) [spring-boot-2.2.0.RELEASE.jar:2.2.0.RELEASE]
	at com.wjf.SpringBootHelloWorldApplication.main(SpringBootHelloWorldApplication.java:7) [classes/:na]
Caused by: org.springframework.context.ApplicationContextException: Unable to start ServletWebServerApplicationContext due to missing ServletWebServerFactory bean.
	at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.getWebServerFactory(ServletWebServerApplicationContext.java:203) ~[spring-boot-2.2.0.RELEASE.jar:2.2.0.RELEASE]
	at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.createWebServer(ServletWebServerApplicationContext.java:179) ~[spring-boot-2.2.0.RELEASE.jar:2.2.0.RELEASE]
	at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:153) ~[spring-boot-2.2.0.RELEASE.jar:2.2.0.RELEASE]
	... 8 common frames omitted


Process finished with exit code 1

老师,想问一下这是什么问题

JAVA 全系列/(旧的隐藏)第十一阶段:spring全家桶(Spring Boot)/Spring Boot 34411楼

# coding=utf-8

import threading
import time
from queue import Queue

class Pro(threading.Thread):
    def run(self):
        global q
        count = 0
        while True:
            if q.qsize()<1000:
                for i in range(100):
                    count += 1
                    msg = "生产"+str(count)
                    q.put(msg) # 往队列中添加新产品
                    print(msg)
            time.sleep(1)


class Con(threading.Thread):
    def run(self):
        global q
        while True:
            if q.qsize() > 100:
                for i in range(150):
                    msg = self.name+"消费"+q.get()
                    print(msg)
            time.sleep(1)


if __name__ == '__main__':
    q = Queue() # 创建队列,线程中能使用
    for i in range(500): # 放500个初始产品
        q.put("初始产品"+str(i))
    for i in range(2): # 两个生产者
        p = Pro()
        p.start()
    for i in range(5):  # 五个消费者
        c = Con()
        c.start()

老师,我给生产者设置的遍历区间是range(100),给消费者设置的是range(150),为什么消费者不能消耗完队列里面的产品,程序一会在执行。还有就是为什么要放入初始500个产品。

Python 全系列/第三阶段:Python 网络与并发编程/并发编程 34414楼
Python 全系列/第十四阶段:Python 爬虫开发/移动端爬虫开发- 34415楼
JAVA 全系列/第一阶段:JAVA 快速入门/面向对象详解和JVM底层内存分析 34418楼
JAVA 全系列/(旧的隐藏)第七阶段:JAVA 高级技术/Solr 34419楼
WEB前端全系列/第六阶段:音乐社区高级项目模块/移动端:基于jQuery使用Ajax和BootStrap 34420楼

 

package com.bjsxt;

import java.sql.*;

public class JdbcTest {

// 向Departments表中添加一条数据

    public void insertDepartments(String department_name,int location_id) {

       Connection conn = null;

       Statement state = null;

    try {

    //驱动注册

    Class.forName("com.mysql.jdbc.Driver");

    //创建连接

    conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/bjsxt?useUnicode=true&characterEncoding=utf-8","root","root");

    //通过Statement 执行sql语句

    String sql = "insert into departments values(default,'"+department_name+"',"+location_id+")";

    state = conn.createStatement();

    int flag = state.executeUpdate(sql);

    System.out.println(flag);

    }catch(Exception e) {

    e.printStackTrace();

    }finally {

    if(state != null) {

    try {

state.close();

} catch (Exception e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

    }

    if(conn != null) {

    try {

conn.close();

} catch (Exception e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

    }

    }

    }

//    更新department表中的department_id 为6的数据 修改名称名为教学部,location_id = 6

    public void updateDepartments(String department_name,int location_id,int department_id) {

    Connection conn = null;

    Statement state = null;

    try {

    Class.forName("com.mysql.jdbc.Driver");

    conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/bjsxt?useUnicode=true&characterEncoding=utf-8","root","root");

    state = conn.createStatement();

    String sql2 = "update departments d set d.department_name = '" +department_name+"',d.location_id"+location_id+"where d.department_id = "+department_id;

    int flag2 = state.executeUpdate(sql2);

    }catch(Exception e) {

    e.printStackTrace();

    }finally {

    if(state != null) {

    try {

state.close();

} catch (Exception e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

    }

    if(conn != null) {

    try {

conn.close();

} catch (Exception e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

    }

   

    }

    }


    public static void main(String[] args) {

    JdbcTest test = new JdbcTest();

//    test.insertDepartments("劳斯莱斯", 4);

    test.updateDepartments("兰博基益",4,7);

    }

}

捕获.JPG


JAVA 全系列/第三阶段:数据库编程/JDBC技术(旧) 34423楼
JAVA 全系列/(旧的隐藏)第八阶段:电商高级项目_架构/编码/电商ego-基于SOA架构_Dubbo使用_逆向工程_分页插件完成商品查询 34425楼

课程分类

百战程序员微信公众号

百战程序员微信小程序

©2014-2025百战汇智(北京)科技有限公司 All Rights Reserved 北京亦庄经济开发区科创十四街 赛蒂国际工业园
网站维护:百战汇智(北京)科技有限公司
京公网安备 11011402011233号    京ICP备18060230号-3    营业执照    经营许可证:京B2-20212637