SpringBoot 启动时 tomcat启动后会停止服务是如何解决

在eclipse 上对项目 运行 spring boot App 没有异常但tomcat 启动后会停止,这是什么原因?
dome参照《Spring boot实战》第二章
版本信息 jdk1.8 本地Tomcat 9.0.11

Log

  :: Spring Boot ::        (v2.0.4.RELEASE)

九月 13, 2018 11:17:54 上午 org.apache.catalina.core.StandardService startInternal
信息: Starting service [Tomcat]
九月 13, 2018 11:17:54 上午 org.apache.catalina.core.StandardEngine startInternal
信息: Starting Servlet Engine: Apache Tomcat/9.0.11
九月 13, 2018 11:17:54 上午 org.apache.catalina.core.AprLifecycleListener lifecycleEvent
信息: Loaded APR based Apache Tomcat Native library [1.2.14] using APR version [1.6.2].
九月 13, 2018 11:17:54 上午 org.apache.catalina.core.AprLifecycleListener lifecycleEvent
信息: APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true].
九月 13, 2018 11:17:54 上午 org.apache.catalina.core.AprLifecycleListener lifecycleEvent
信息: APR/OpenSSL configuration: useAprConnector [false], useOpenSSL [true]
九月 13, 2018 11:17:55 上午 org.apache.catalina.core.AprLifecycleListener initializeSSL
信息: OpenSSL successfully initialized [OpenSSL 1.0.2l  25 May 2017]
九月 13, 2018 11:17:55 上午 org.apache.catalina.core.ApplicationContext log
信息: Initializing Spring embedded WebApplicationContext
九月 13, 2018 11:17:55 上午 org.apache.catalina.core.StandardService stopInternal
信息: Stopping service [Tomcat]

pox.xml配置

 <?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.example</groupId>
    <artifactId>readinglist</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>

    <name>readinglist</name>
    <description>Demo project for Spring Boot</description>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.0.4.RELEASE</version>
        <relativePath /> <!-- lookup parent from repository -->
    </parent>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <java.version>1.8</java.version>
        <tomcat.version>9.0.11</tomcat.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-thymeleaf</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>ch.qos.logback</groupId>
            <artifactId>logback-classic</artifactId>
            <version>1.3.0-alpha4</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
            <version>2.9.6</version>
        </dependency>
        <dependency>
            <groupId>org.apache.tomcat</groupId>
            <artifactId>tomcat-juli</artifactId>
            <version>${tomcat.version}</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-nop</artifactId>
            <version>1.7.2</version>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>


</project>

2个回答

springboot集成了tomcat使用maven启动的,所以你可以启动,如果你想用第三方的ttomcat你需要把pom的jar包换成war,然后引入tomcat包

环境有问题 应该是缺失一些jar

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
SpringBoot如何停止内置的tomcat的?

SpringBoot在启动的时候,如果bean配置有问题,就直接会把tomcat停止掉, 这是怎么停止的。我有个配置文件,在加载过程中,我想把Spring停掉,把内置的tomca也停止运行,怎么做?有大佬晓得不?

springboot程序不能启动

2019-03-15 16:50:33.588 INFO 12140 --- [ main] c.h.s.SpringBoot01Application : Starting SpringBoot01Application on DESKTOP-QUO396V with PID 12140 (F:\Ideal\spring-boot-01\target\classes started by PC in F:\Ideal\spring-boot-01) 2019-03-15 16:50:33.635 INFO 12140 --- [ main] c.h.s.SpringBoot01Application : No active profile set, falling back to default profiles: default 2019-03-15 16:50:35.666 INFO 12140 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http) 2019-03-15 16:50:35.744 INFO 12140 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat] 2019-03-15 16:50:35.744 INFO 12140 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.16] 2019-03-15 16:50:35.744 INFO 12140 --- [ main] o.a.catalina.core.AprLifecycleListener : The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: [E:\JDK\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;E:\xftp\;E:\xshell\;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;E:\JDK\bin;E:\mysql-8.0.14-winx64\mysql-8.0.14-winx64\bin;E:\apache-maven-3.3.9\bin;E:\git\Git\cmd;C:\Users\PC\AppData\Local\Microsoft\WindowsApps;C:\Users\PC\AppData\Local\Pandoc\;.] 2019-03-15 16:50:36.073 INFO 12140 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext 2019-03-15 16:50:36.073 INFO 12140 --- [ main] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 2391 ms 2019-03-15 16:50:36.307 INFO 12140 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor' 2019-03-15 16:50:36.541 INFO 12140 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path '' 2019-03-15 16:50:36.572 INFO 12140 --- [ main] c.h.s.SpringBoot01Application : Started SpringBoot01Application in 3.702 seconds (JVM running for 6.318) 为什么springboot程序启动不起来

linux下tomcat运行一段时间后 异常停止

停止时会打印如下日志: 30-Jul-2018 13:23:56.786 INFO [Thread-8] org.apache.coyote.AbstractProtocol.pause Pausing ProtocolHandler ["http-nio-10001"] 30-Jul-2018 13:23:56.839 INFO [Thread-8] org.apache.coyote.AbstractProtocol.pause Pausing ProtocolHandler ["ajp-nio-9009"] 30-Jul-2018 13:23:56.890 INFO [Thread-8] org.apache.catalina.core.StandardService.stopInternal Stopping service [Catalina] 2018-07-30 13:23:56,894 [localhost-startStop-2] INFO [org.springframework.web.context.support.XmlWebApplicationContext] - Closing WebApplicationContext for namespace 'spring-servlet': startup date [Mon Jul 30 12:29:02 CST 2018]; parent: Root WebApplicationContext 2018-07-30 13:23:56,898 [localhost-startStop-2] INFO [org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler] - Shutting down ExecutorService 'qbScheduler' 2018-07-30 13:23:56,918 [localhost-startStop-2] INFO [org.springframework.web.context.support.XmlWebApplicationContext] - Closing Root WebApplicationContext: startup date [Mon Jul 30 12:28:53 CST 2018]; root of context hierarchy 2018-07-30 13:23:56,925 [localhost-startStop-2] INFO [com.alibaba.druid.pool.DruidDataSource] - {dataSource-1} closed 30-Jul-2018 13:23:56.930 WARNING [localhost-startStop-2] org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesJdbc The web application [hours] registered the JDBC driver [com.alibaba.druid.proxy.DruidDriver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered. 30-Jul-2018 13:23:56.931 WARNING [localhost-startStop-2] org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesJdbc The web application [hours] registered the JDBC driver [com.mysql.jdbc.Driver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered. 30-Jul-2018 13:23:56.939 WARNING [localhost-startStop-2] org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesThreads The web application [hours] appears to have started a thread named [MySQL Statement Cancellation Timer] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread: java.lang.Object.wait(Native Method) java.lang.Object.wait(Object.java:502) java.util.TimerThread.mainLoop(Timer.java:526) java.util.TimerThread.run(Timer.java:505) 30-Jul-2018 13:23:56.940 SEVERE [localhost-startStop-2] org.apache.catalina.loader.WebappClassLoaderBase.checkThreadLocalMapForLeaks The web application [hours] created a ThreadLocal with key of type [java.lang.ThreadLocal] (value [java.lang.ThreadLocal@2dbd390a]) and a value of type [com.alibaba.druid.wall.spi.WallVisitorUtils.WallTopStatementContext] (value [com.alibaba.druid.wall.spi.WallVisitorUtils$WallTopStatementContext@6d274589]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak. ![图片说明](https://img-ask.csdn.net/upload/201807/30/1532934549_542642.png)

spring boot 项目启动卡住了

![图片说明](https://img-ask.csdn.net/upload/201901/24/1548296259_465769.png) 一直卡在这里不动了,项目也没报错,

Tomcat运行一段时间后就会挂掉,时间不确定,一会几天,一会几分钟,请大神看看

因为是服务器的原因,断了之后再链接只能看到以下日志, ``` at com.sun.jmx.mbeanserver.JmxMBeanServer.unregisterMBean(JmxMBeanServer.java:546) at org.apache.catalina.util.LifecycleMBeanBase.unregister(LifecycleMBeanBase.java:194) at org.apache.catalina.util.LifecycleMBeanBase.destroyInternal(LifecycleMBeanBase.java:73) at org.apache.catalina.core.StandardService.destroyInternal(StandardService.java:597) at org.apache.catalina.util.LifecycleBase.destroy(LifecycleBase.java:292) at org.apache.catalina.core.StandardServer.destroyInternal(StandardServer.java:848) at org.apache.catalina.util.LifecycleBase.destroy(LifecycleBase.java:292) at org.apache.catalina.startup.Catalina.stop(Catalina.java:768) at org.apache.catalina.startup.Catalina$CatalinaShutdownHook.run(Catalina.java:913) ```

Springboot项目部署问题

本地测试没有问题,但是部署上服务器后,出现部分地址能访问,但是某些JSP页面找不着 ERROR ErrorPageFilter:225 - Cannot forward to error page for request [/qrCode/statement] as the response has already been committed. As a result, the response may have the wrong status code. If your application is running on WebSphere Application Server you may be able to resolve this problem by setting com.ibm.ws.webcontainer.invokeFlushAfterService to false 本地测试一点问题没有,Jenkins,部署完成后,访问时出现这个问题,但是也有些网也能访问 是URL的问题,还是什么原因呢个,请大神指导1

idea启动程序后直接退出控制台Process finished with exit code 0

![图片说明](https://img-ask.csdn.net/upload/201710/06/1507268269_946317.png) 也就是把整个springboot的内嵌tomcat也停止了,怎么设置成eclipse那样启动后不自动退出控制台?求大神解答

springboot使用ehcache缓存,有些数据重启后不希望消失,怎么持久化到硬盘并在重启后恢复呢

如果每次调flush刷新到硬盘在性能上会得不偿失,所以我希望的是在tomcat关闭时将数据刷到硬盘并在启动时恢复,目前 在启动类上加上了监听 ``` @ServletComponentScan(basePackageClasses = {net.sf.ehcache.constructs.web.ShutdownListener.class}) ``` ![图片说明](https://img-ask.csdn.net/upload/201911/23/1574475880_387136.png) 并没有什么作用,不知道哪出问题了

idea spring boot启动失败

每次启动spring boot都自动停止了,提示Disconnected from the target VM, address: '127.0.0.1:XXXXX', transport: 'socket',每次端口都不一样,重启idea杀掉后台进程都不行,不知道为什么,新建一个空项目也是这样的问题,但是跑以前建的demo就没这个问题,求大神指导!!!

linux部署tomcat启动出问题,求大神们指教错在哪啊

2016-7-14 10:40:07 org.apache.catalina.core.AprLifecycleListener init 信息: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: /home/admin/upay/jdk1.6.0_43/jre/lib/amd64/server:/home/admin/upay/jdk1.6.0_43/jre/lib/amd64:/home/admin/upay/jdk1.6.0_43/jre/../lib/amd64:/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib 2016-7-14 10:40:08 org.apache.coyote.http11.Http11Protocol init 信息: Initializing Coyote HTTP/1.1 on http-9111 2016-7-14 10:40:08 org.apache.catalina.startup.Catalina load 信息: Initialization processed in 556 ms 2016-7-14 10:40:08 org.apache.catalina.core.StandardService start 信息: Starting service Catalina 2016-7-14 10:40:08 org.apache.catalina.core.StandardEngine start 信息: Starting Servlet Engine: Apache Tomcat/6.0.37 2016-7-14 10:40:08 org.apache.catalina.startup.HostConfig deployDirectory 信息: Deploying web application directory CMUPayBankFront 2016-7-14 10:40:08 org.apache.catalina.loader.WebappClassLoader validateJarFile 信息: validateJarFile(/opt/mcb/bank_tomcat/webapps/CMUPayBankFront/WEB-INF/lib/servlet-api-2.5.jar) - jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/servlet/Servlet.class 10:40:08,820 |-INFO in ch.qos.logback.classic.LoggerContext[CMUPayBankFront] - Could NOT find resource [logback.groovy] 10:40:08,820 |-INFO in ch.qos.logback.classic.LoggerContext[CMUPayBankFront] - Could NOT find resource [logback-test.xml] 10:40:08,821 |-INFO in ch.qos.logback.classic.LoggerContext[CMUPayBankFront] - Found resource [logback.xml] at [file:/opt/mcb/bank_tomcat/webapps/CMUPayBankFront/WEB-INF/classes/logback.xml] 10:40:08,976 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - debug attribute not set 10:40:08,987 |-INFO in ch.qos.logback.classic.joran.action.ContextNameAction - Setting logger context name as [CMUPayBankFront] 10:40:08,988 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.core.rolling.RollingFileAppender] 10:40:08,999 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [FILE] 10:40:09,074 |-INFO in c.q.l.core.rolling.TimeBasedRollingPolicy - No compression will be used 10:40:09,076 |-INFO in c.q.l.core.rolling.TimeBasedRollingPolicy - Will use the pattern /opt/mcb/upaysys/logs/CMUPayBankFront/CMUPayBankFront_%d{yyyy-MM-dd}_%i.log for the active file 10:40:09,079 |-INFO in ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP@6477eb97 - The date pattern is 'yyyy-MM-dd' from file name pattern '/opt/mcb/upaysys/logs/CMUPayBankFront/CMUPayBankFront_%d{yyyy-MM-dd}_%i.log'. 10:40:09,079 |-INFO in ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP@6477eb97 - Roll-over at midnight. 10:40:09,083 |-INFO in ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP@6477eb97 - Setting initial period to Thu Jul 14 10:40:09 EDT 2016 10:40:09,086 |-INFO in ch.qos.logback.core.joran.action.NestedComplexPropertyIA - Assuming default type [ch.qos.logback.classic.encoder.PatternLayoutEncoder] for [encoder] property 10:40:09,130 |-INFO in ch.qos.logback.core.rolling.RollingFileAppender[FILE] - Active log file name: /opt/mcb/upaysys/logs/CMUPayBankFront/CMUPayBankFront_2016-07-14_0.log 10:40:09,130 |-INFO in ch.qos.logback.core.rolling.RollingFileAppender[FILE] - File property is set to [null] 10:40:09,131 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.core.FileAppender] 10:40:09,131 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [OPERATE_FILE] 10:40:09,132 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@64:13 - no applicable action for [Encoding], current ElementPath is [[configuration][appender][Encoding]] 10:40:09,132 |-INFO in ch.qos.logback.core.joran.action.NestedComplexPropertyIA - Assuming default type [ch.qos.logback.classic.encoder.PatternLayoutEncoder] for [encoder] property 10:40:09,133 |-INFO in ch.qos.logback.core.FileAppender[OPERATE_FILE] - File property is set to [/tlqnew/ljjkfile/sndfile//CMUPayBankFront.txt] 10:40:09,133 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [com.huateng.log.CustomMonitorAppender] 10:40:09,134 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [OPERATE_FILE_DAILY] 10:40:09,143 |-INFO in c.q.l.core.rolling.TimeBasedRollingPolicy - No compression will be used 10:40:09,143 |-INFO in c.q.l.core.rolling.TimeBasedRollingPolicy - Will use the pattern /opt/mcb/upay/var/log/CMUPayBankFront_%i.log.%d{yyyyMMdd} for the active file 10:40:09,144 |-INFO in ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP@7d0c3a08 - The date pattern is 'yyyyMMdd' from file name pattern '/opt/mcb/upay/var/log/CMUPayBankFront_%i.log.%d{yyyyMMdd}'. 10:40:09,144 |-INFO in ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP@7d0c3a08 - Roll-over at midnight. 10:40:09,144 |-INFO in ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP@7d0c3a08 - Setting initial period to Thu Jul 14 10:40:09 EDT 2016 10:40:09,201 |-INFO in com.huateng.log.CustomMonitorAppender[OPERATE_FILE_DAILY] - Active log file name: /opt/mcb/upay/var/log/CMUPayBankFront_0.log.20160714 10:40:09,201 |-INFO in com.huateng.log.CustomMonitorAppender[OPERATE_FILE_DAILY] - File property is set to [null] 10:40:09,202 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [com.huateng.log.LogHandleImpl] to INFO 10:40:09,202 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting additivity of logger [com.huateng.log.LogHandleImpl] to false 10:40:09,202 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [OPERATE_FILE] to Logger[com.huateng.log.LogHandleImpl] 10:40:09,203 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [com.huateng.bank.logFormat.MessageLogger] to WARN 10:40:09,203 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting additivity of logger [com.huateng.bank.logFormat.MessageLogger] to false 10:40:09,203 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [OPERATE_FILE_DAILY] to Logger[com.huateng.bank.logFormat.MessageLogger] 10:40:09,203 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [com.huateng.bank.listener] to WARN 10:40:09,203 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting additivity of logger [com.huateng.bank.listener] to false 10:40:09,203 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [OPERATE_FILE_DAILY] to Logger[com.huateng.bank.listener] 10:40:09,203 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [org.apache.activemq.transport.failover] to WARN 10:40:09,203 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting additivity of logger [org.apache.activemq.transport.failover] to false 10:40:09,203 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [OPERATE_FILE_DAILY] to Logger[org.apache.activemq.transport.failover] 10:40:09,203 |-INFO in ch.qos.logback.classic.joran.action.RootLoggerAction - Setting level of ROOT logger to INFO 10:40:09,203 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [FILE] to Logger[ROOT] 10:40:09,203 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - End of configuration. 10:40:09,215 |-INFO in ch.qos.logback.classic.joran.JoranConfigurator@2db6235b - Registering current configuration as safe fallback point 2016-7-14 10:40:10 org.apache.catalina.core.StandardContext start 严重: Error listenerStart 2016-7-14 10:40:10 org.apache.catalina.core.StandardContext start 严重: Context [/CMUPayBankFront] startup failed due to previous errors 2016-7-14 10:40:10 org.apache.coyote.http11.Http11Protocol start 信息: Starting Coyote HTTP/1.1 on http-9111 2016-7-14 10:40:10 org.apache.jk.common.ChannelSocket init 信息: JK: ajp13 listening on /0.0.0.0:9101 2016-7-14 10:40:10 org.apache.jk.server.JkMain start 信息: Jk running ID=0 time=0/59 config=null 2016-7-14 10:40:10 org.apache.catalina.startup.Catalina start 信息: Server startup in 2666 ms

定时任务quartz开启线程,在tomcat关闭时候,报内存泄露,如何解决?

报错内容如下 [INFO][2018-08-24 21:30:11] com.alibaba.druid.pool.DruidDataSource.close(DruidDataSource.java:1825) {dataSource-1} closed 24-Aug-2018 21:30:11.702 警告 [localhost-startStop-2] org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesThreads The web application [ROOT] appears to have started a thread named [pool-2-thread-1] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread: sun.misc.Unsafe.park(Native Method) java.util.concurrent.locks.LockSupport.park(LockSupport.java:186) java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2043) java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:442) java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1068) java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130) java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) java.lang.Thread.run(Thread.java:745) 24-Aug-2018 21:30:11.702 警告 [localhost-startStop-2] org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesThreads The web application [ROOT] appears to have started a thread named [pool-3-thread-1] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread: sun.misc.Unsafe.park(Native Method) java.util.concurrent.locks.LockSupport.park(LockSupport.java:186) java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2043) java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:442) java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1068) java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130) java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) java.lang.Thread.run(Thread.java:745) 24-Aug-2018 21:30:11.703 警告 [localhost-startStop-2] org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesThreads The web application [ROOT] appears to have started a thread named [pool-4-thread-1] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread: sun.misc.Unsafe.park(Native Method) java.util.concurrent.locks.LockSupport.park(LockSupport.java:186) java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2043) java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:442) java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1068) java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130) java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) java.lang.Thread.run(Thread.java:745) 24-Aug-2018 21:30:11.705 信息 [main] org.apache.coyote.AbstractProtocol.stop Stopping ProtocolHandler ["http-apr-8080"] 24-Aug-2018 21:30:11.773 信息 [main] org.apache.coyote.AbstractProtocol.stop Stopping ProtocolHandler ["ajp-apr-8009"] 24-Aug-2018 21:30:11.825 信息 [main] org.apache.coyote.AbstractProtocol.destroy Destroying ProtocolHandler ["http-apr-8080"] 24-Aug-2018 21:30:11.826 信息 [main] org.apache.coyote.AbstractProtocol.destroy Destroying ProtocolHandler ["ajp-apr-8009"] ``` ``` 根据网上的解决方法,我已经关闭了定时任务Scheduler,关闭了开启定时任务的线程池,也关闭了数据源。为什么还是报错? 我的代码 package com.yz.robot.spring; import com.yz.robot.mcore.utils.SpringContextUtils; import com.yz.robot.mquartz.service.ScheduleJobService; import com.yz.robot.mquartz.service.impl.ScheduleJobServiceImpl; import com.yz.robot.mquartz.utils.ScheduleJob; import org.quartz.Scheduler; import org.quartz.SchedulerException; import org.quartz.impl.StdSchedulerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.context.WebApplicationContext; import org.springframework.web.context.support.WebApplicationContextUtils; import javax.servlet.ServletContextEvent; import javax.servlet.ServletContextListener; import java.sql.Driver; import java.sql.DriverManager; import java.util.Enumeration; import java.util.List; import java.util.Set; import java.util.concurrent.ExecutorService; public class QuartzJobListener implements ServletContextListener { @Autowired private ScheduleJob scheduleJob; @Override public void contextInitialized(ServletContextEvent sce) { System.out.println("--------------开始-------"); } @Override public void contextDestroyed(ServletContextEvent sce){ WebApplicationContext webApplicationContext = WebApplicationContextUtils.getWebApplicationContext(sce.getServletContext()); if (webApplicationContext != null){ Object scheduleJobServiceImpl = webApplicationContext.getBean("scheduleJob"); System.out.println("-------------------------2"); System.out.println(scheduleJobServiceImpl !=null); }else { System.out.println("获取应用程序上下文失败!"); } try { Scheduler defaultScheduler = StdSchedulerFactory.getDefaultScheduler(); System.out.println("-------------------------2"); System.out.println(defaultScheduler.isShutdown()); defaultScheduler.shutdown(true); Thread.sleep(1000); System.out.println(defaultScheduler.isShutdown()); ScheduleJob scheduleJob = (ScheduleJob) SpringContextUtils.getBean("scheduleJob"); //scheduleJobServiceImpl ExecutorService service = scheduleJob.getService(); System.out.println("-------------------------3"); System.out.println(service!=null); System.out.println(service.isShutdown()); List<Runnable> runnables = service.shutdownNow(); System.out.println(service.isShutdown()); Thread.sleep(1000); System.out.println("-------------------------4"); Enumeration<Driver> drivers = DriverManager.getDrivers(); while (drivers.hasMoreElements()){ Driver driver = drivers.nextElement(); DriverManager.deregisterDriver(driver); System.out.println("又注销了一个driver"+driver.toString()); } } catch (Exception e) { e.printStackTrace(); } } } 大佬们帮帮我吧??? ```

Spring Boot项目启动问题

## eclipse的Spring Boot项目启动过程中,日志记录信息: ``` 2019-03-01 18:02:27.998 [main] INFO o.s.c.a.AnnotationConfigApplicationContext - Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@7b1d7fff: startup date [Fri Mar 01 18:02:27 CST 2019]; root of context hierarchy 2019-03-01 18:02:28.545 [main] INFO o.s.b.f.a.AutowiredAnnotationBeanPostProcessor - JSR-330 'javax.inject.Inject' annotation found and supported for autowiring 2019-03-01 18:02:28.592 [main] INFO o.s.c.s.PostProcessorRegistrationDelegate$BeanPostProcessorChecker - Bean 'configurationPropertiesRebinderAutoConfiguration' of type [class org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration$$EnhancerBySpringCGLIB$$870ef58b] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying) ``` ## 希望大能帮忙解决一下问题,万分感谢

Spring框架入门,tomcat启动成功,但是出现关于上下文加载异常?

这是一个制作登陆页面的小练习,大概长这样 ![图片说明](https://img-ask.csdn.net/upload/201907/20/1563604903_663111.png) **错误信息是在Server startup后立马就出现的**,还没来得及访问index.jsp呢!求指点,谢谢。 web.xml存放在WEB-INF文件夹下 ![图片说明](https://img-ask.csdn.net/upload/201907/20/1563607667_370819.png) ## 错误信息: ``` 七月 20, 2019 3:20:35 下午 org.apache.catalina.startup.VersionLoggerListener log 信息: Server version: Apache Tomcat/8.5.42 七月 20, 2019 3:20:35 下午 org.apache.catalina.startup.VersionLoggerListener log 信息: Server built: Jun 4 2019 20:29:04 UTC 七月 20, 2019 3:20:35 下午 org.apache.catalina.startup.VersionLoggerListener log 信息: Server number: 8.5.42.0 七月 20, 2019 3:20:35 下午 org.apache.catalina.startup.VersionLoggerListener log 信息: OS Name: Windows 10 七月 20, 2019 3:20:35 下午 org.apache.catalina.startup.VersionLoggerListener log 信息: OS Version: 10.0 七月 20, 2019 3:20:35 下午 org.apache.catalina.startup.VersionLoggerListener log 信息: Architecture: amd64 七月 20, 2019 3:20:35 下午 org.apache.catalina.startup.VersionLoggerListener log 信息: Java Home: C:\Program Files\Java\jdk1.8.0_201\jre 七月 20, 2019 3:20:35 下午 org.apache.catalina.startup.VersionLoggerListener log 信息: JVM Version: 1.8.0_201-b09 七月 20, 2019 3:20:35 下午 org.apache.catalina.startup.VersionLoggerListener log 信息: JVM Vendor: Oracle Corporation 七月 20, 2019 3:20:35 下午 org.apache.catalina.startup.VersionLoggerListener log 信息: CATALINA_BASE: D:\eclipse-workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0 七月 20, 2019 3:20:35 下午 org.apache.catalina.startup.VersionLoggerListener log 信息: CATALINA_HOME: D:\apache-tomcat-8.5.42 七月 20, 2019 3:20:35 下午 org.apache.catalina.startup.VersionLoggerListener log 信息: Command line argument: -Dcatalina.base=D:\eclipse-workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0 七月 20, 2019 3:20:35 下午 org.apache.catalina.startup.VersionLoggerListener log 信息: Command line argument: -Dcatalina.home=D:\apache-tomcat-8.5.42 七月 20, 2019 3:20:35 下午 org.apache.catalina.startup.VersionLoggerListener log 信息: Command line argument: -Dwtp.deploy=D:\eclipse-workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps 七月 20, 2019 3:20:35 下午 org.apache.catalina.startup.VersionLoggerListener log 信息: Command line argument: -Djava.endorsed.dirs=D:\apache-tomcat-8.5.42\endorsed 七月 20, 2019 3:20:35 下午 org.apache.catalina.startup.VersionLoggerListener log 信息: Command line argument: -Dfile.encoding=UTF-8 七月 20, 2019 3:20:35 下午 org.apache.catalina.core.AprLifecycleListener lifecycleEvent 信息: Loaded APR based Apache Tomcat Native library [1.2.21] using APR version [1.6.5]. 七月 20, 2019 3:20:35 下午 org.apache.catalina.core.AprLifecycleListener lifecycleEvent 信息: APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true]. 七月 20, 2019 3:20:35 下午 org.apache.catalina.core.AprLifecycleListener lifecycleEvent 信息: APR/OpenSSL configuration: useAprConnector [false], useOpenSSL [true] 七月 20, 2019 3:20:35 下午 org.apache.catalina.core.AprLifecycleListener initializeSSL 信息: OpenSSL successfully initialized [OpenSSL 1.1.1a 20 Nov 2018] 七月 20, 2019 3:20:35 下午 org.apache.coyote.AbstractProtocol init 信息: Initializing ProtocolHandler ["http-nio-8080"] 七月 20, 2019 3:20:36 下午 org.apache.tomcat.util.net.NioSelectorPool getSharedSelector 信息: Using a shared selector for servlet write/read 七月 20, 2019 3:20:36 下午 org.apache.coyote.AbstractProtocol init 信息: Initializing ProtocolHandler ["ajp-nio-8009"] 七月 20, 2019 3:20:36 下午 org.apache.tomcat.util.net.NioSelectorPool getSharedSelector 信息: Using a shared selector for servlet write/read 七月 20, 2019 3:20:36 下午 org.apache.catalina.startup.Catalina load 信息: Initialization processed in 1265 ms 七月 20, 2019 3:20:36 下午 org.apache.catalina.core.StandardService startInternal 信息: Starting service [Catalina] 七月 20, 2019 3:20:36 下午 org.apache.catalina.core.StandardEngine startInternal 信息: Starting Servlet Engine: Apache Tomcat/8.5.42 七月 20, 2019 3:20:39 下午 org.apache.catalina.core.ApplicationContext log 信息: No Spring WebApplicationInitializer types detected on classpath 七月 20, 2019 3:20:39 下午 org.apache.jasper.servlet.TldScanner scanJars 信息: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time. 七月 20, 2019 3:20:39 下午 org.apache.catalina.core.ApplicationContext log 信息: Initializing Spring root WebApplicationContext log4j:WARN No appenders could be found for logger (org.springframework.web.context.ContextLoader). log4j:WARN Please initialize the log4j system properly. log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info. 七月 20, 2019 3:20:42 下午 org.apache.catalina.core.StandardContext listenerStart 严重: Exception sending context initialized event to listener instance of class [org.springframework.web.context.ContextLoaderListener] org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'usersService' defined in class path resource [applicationContext.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'usersMapper' of bean class [yan.ibbie.service.impl.UsersServiceImpl]: Bean property 'usersMapper' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter? at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1718) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1433) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:592) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:515) at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:845) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:877) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:549) at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:400) at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:291) at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:103) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4770) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5236) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1423) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1413) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748) Caused by: org.springframework.beans.NotWritablePropertyException: Invalid property 'usersMapper' of bean class [yan.ibbie.service.impl.UsersServiceImpl]: Bean property 'usersMapper' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter? at org.springframework.beans.BeanWrapperImpl.createNotWritablePropertyException(BeanWrapperImpl.java:243) at org.springframework.beans.AbstractNestablePropertyAccessor.processLocalProperty(AbstractNestablePropertyAccessor.java:426) at org.springframework.beans.AbstractNestablePropertyAccessor.setPropertyValue(AbstractNestablePropertyAccessor.java:278) at org.springframework.beans.AbstractNestablePropertyAccessor.setPropertyValue(AbstractNestablePropertyAccessor.java:266) at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:97) at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:77) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1714) ... 22 more 七月 20, 2019 3:20:42 下午 org.apache.catalina.core.StandardContext startInternal 严重: One or more listeners failed to start. Full details will be found in the appropriate container log file 七月 20, 2019 3:20:42 下午 org.apache.catalina.core.StandardContext startInternal 严重: Context [/SpringLogin] startup failed due to previous errors 七月 20, 2019 3:20:42 下午 org.apache.catalina.core.ApplicationContext log 信息: Closing Spring root WebApplicationContext 七月 20, 2019 3:20:42 下午 org.apache.catalina.loader.WebappClassLoaderBase clearReferencesJdbc 警告: The web application [SpringLogin] registered the JDBC driver [com.mysql.cj.jdbc.Driver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered. 七月 20, 2019 3:20:42 下午 org.apache.catalina.loader.WebappClassLoaderBase clearReferencesThreads 警告: The web application [SpringLogin] appears to have started a thread named [mysql-cj-abandoned-connection-cleanup] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread: java.lang.Object.wait(Native Method) java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:144) com.mysql.cj.jdbc.AbandonedConnectionCleanupThread.run(AbandonedConnectionCleanupThread.java:85) java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) java.lang.Thread.run(Thread.java:748) 七月 20, 2019 3:20:42 下午 org.apache.coyote.AbstractProtocol start 信息: Starting ProtocolHandler ["http-nio-8080"] 七月 20, 2019 3:20:42 下午 org.apache.coyote.AbstractProtocol start 信息: Starting ProtocolHandler ["ajp-nio-8009"] 七月 20, 2019 3:20:42 下午 org.apache.catalina.startup.Catalina start 信息: Server startup in 5949 ms 七月 20, 2019 3:20:45 下午 org.apache.catalina.loader.WebappClassLoaderBase checkStateForResourceLoading 信息: Illegal access: this web application instance has been stopped already. Could not load []. The following stack trace is thrown for debugging purposes as well as to attempt to terminate the thread which caused the illegal access. java.lang.IllegalStateException: Illegal access: this web application instance has been stopped already. Could not load []. The following stack trace is thrown for debugging purposes as well as to attempt to terminate the thread which caused the illegal access. at org.apache.catalina.loader.WebappClassLoaderBase.checkStateForResourceLoading(WebappClassLoaderBase.java:1384) at org.apache.catalina.loader.WebappClassLoaderBase.getResource(WebappClassLoaderBase.java:1034) at com.mysql.cj.jdbc.AbandonedConnectionCleanupThread.checkThreadContextClassLoader(AbandonedConnectionCleanupThread.java:117) at com.mysql.cj.jdbc.AbandonedConnectionCleanupThread.run(AbandonedConnectionCleanupThread.java:84) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748) ``` ## web.xml配置如下: ``` <?xml version="1.0" encoding="UTF-8"?> <web-app version="3.1" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"> <!-- 设置Spring配置文件路径 --> <!-- 当tomcat加载web.xml时,会把Spring配置文件信息存放到application对象 --> <!-- WebApplicationContext是ApplicationContext的子接口 --> <context-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:applicationContext.xml</param-value> </context-param> <!-- 加载Spring配置文件 --> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> </web-app> ``` ## applicationContext.xml的Spring配置如下: ``` <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd"> <!-- 数据源封装类 --> <bean id="datasource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"> <property name="driverClassName" value="com.mysql.cj.jdbc.Driver"/> <property name="url" value="jdbc:mysql://localhost:3306/ssm?serverTimezone=GMT%2B8"/> <property name="username" value="root"/> <property name="password" value="147852369"/> </bean> <!-- SqlSessionFactory --> <bean id="factory" class="org.mybatis.spring.SqlSessionFactoryBean"> <property name="dataSource" ref="datasource"/> </bean> <!-- 扫描器 --> <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer"> <property name="sqlSessionFactory" ref="factory"/> <property name="basePackage" value="yan.ibbie.mapper"/> </bean> <!-- 创建UsersService的实现类,其中usersMapper是Spring自动创建的bean --> <bean id="usersService" class="yan.ibbie.service.impl.UsersServiceImpl"> <property name="usersMapper" ref="usersMapper"/> </bean> </beans> ``` ## index.jsp页面如下: ``` <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Insert title here</title> <script type="text/javascript" src="/js/jquery-3.4.1.js"></script> <script type="text/javascript"> $(function(){ $("a").click(function(){ $("img").attr("src","validcode?date="+new Date()); return false; }) }) </script> </head> <body> ${error } <form action="Login" method="post"> 用户名:<input type="text" name="username" /><br> 密码:<input type="password" name="password" /><br> 验证码:<input type="text" size="1" name="code"/><img src="validcode" width="80" height="40"/><a href="">看不清</a><br> <input type="submit" value="登陆" /><input type="reset" value="重置" /> </form> </body> </html> ``` ## 出错的是LoginServlet中一堆aaaaa那行,LoginServlet如下: ``` package yan.ibbie.servlet; import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import org.springframework.context.ApplicationContext; import org.springframework.web.context.support.WebApplicationContextUtils; import yan.ibbie.pojo.Users; import yan.ibbie.service.UsersService; import yan.ibbie.service.impl.UsersServiceImpl; /** * Servlet implementation class LoginServlet */ @WebServlet("/Login") public class LoginServlet extends HttpServlet { private static final long serialVersionUID = 1L; private UsersService usersService; @Override public void init() throws ServletException { System.out.println("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"+getServletContext()); ApplicationContext ac = WebApplicationContextUtils.getRequiredWebApplicationContext(getServletContext()); usersService = ac.getBean("usersService",UsersServiceImpl.class); } @Override protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { String code = req.getParameter("code"); HttpSession session = req.getSession(); String codeSession = session.getAttribute("validcode").toString(); if (codeSession.equals(code)) { Users users = new Users(); String username = req.getParameter("username"); String password = req.getParameter("password"); users.setUsername(username); users.setPasserword(password); Users user = usersService.login(users); if (user!=null) { resp.sendRedirect("main.jsp"); }else { req.setAttribute("error", "用户名和密码不正确"); req.getRequestDispatcher("index.jsp").forward(req, resp); } }else { req.setAttribute("error", "验证码不正确"); req.getRequestDispatcher("index.jsp").forward(req, resp); } } } ```

IntelliJ idea Web项目配置问题(JDBC驱动注册失败)

今天想要把开发工具从Eclipse换成Intellij idea。于是把一个在Eclipse中开发的项目导入到了idea。各种配置完之后,项目可以启动,可以打开主页,但是无法登陆系统。控制台打印JDBC驱动注册失败,如图。请问这个问题怎么解决啊!各位大哥帮帮忙,小弟谢过啦! ![图片说明](https://img-ask.csdn.net/upload/201707/07/1499410224_172849.png) ![图片说明](https://img-ask.csdn.net/upload/201707/07/1499410236_207775.png) ![图片说明](https://img-ask.csdn.net/upload/201707/07/1499410249_960795.png) 另外数据库连接是没问题的。在Eclipse中启动也没有问题

在中国程序员是青春饭吗?

今年,我也32了 ,为了不给大家误导,咨询了猎头、圈内好友,以及年过35岁的几位老程序员……舍了老脸去揭人家伤疤……希望能给大家以帮助,记得帮我点赞哦。 目录: 你以为的人生 一次又一次的伤害 猎头界的真相 如何应对互联网行业的「中年危机」 一、你以为的人生 刚入行时,拿着傲人的工资,想着好好干,以为我们的人生是这样的: 等真到了那一天,你会发现,你的人生很可能是这样的: ...

再不跳槽,应届毕业生拿的都比我多了!

跳槽几乎是每个人职业生涯的一部分,很多HR说“三年两跳”已经是一个跳槽频繁与否的阈值了,可为什么市面上有很多程序员不到一年就跳槽呢?他们不担心影响履历吗? PayScale之前发布的**《员工最短任期公司排行榜》中,两家码农大厂Amazon和Google**,以1年和1.1年的员工任期中位数分列第二、第四名。 PayScale:员工最短任期公司排行榜 意外的是,任期中位数极小的这两家公司,薪资...

我以为我学懂了数据结构,直到看了这个导图才发现,我错了

数据结构与算法思维导图

数据库——玩转SQL语句(以MySQL为例)

一、前言 照着大学的SQL server来学

技术大佬:我去,你写的 switch 语句也太老土了吧

昨天早上通过远程的方式 review 了两名新来同事的代码,大部分代码都写得很漂亮,严谨的同时注释也很到位,这令我非常满意。但当我看到他们当中有一个人写的 switch 语句时,还是忍不住破口大骂:“我擦,小王,你丫写的 switch 语句也太老土了吧!” 来看看小王写的代码吧,看完不要骂我装逼啊。 private static String createPlayer(PlayerTypes p...

华为初面+综合面试(Java技术面)附上面试题

华为面试整体流程大致分为笔试,性格测试,面试,综合面试,回学校等结果。笔试来说,华为的难度较中等,选择题难度和网易腾讯差不多。最后的代码题,相比下来就简单很多,一共3道题目,前2题很容易就AC,题目已经记不太清楚,不过难度确实不大。最后一题最后提交的代码过了75%的样例,一直没有发现剩下的25%可能存在什么坑。 笔试部分太久远,我就不怎么回忆了。直接将面试。 面试 如果说腾讯的面试是挥金如土...

和黑客斗争的 6 天!

互联网公司工作,很难避免不和黑客们打交道,我呆过的两家互联网公司,几乎每月每天每分钟都有黑客在公司网站上扫描。有的是寻找 Sql 注入的缺口,有的是寻找线上服务器可能存在的漏洞,大部分都...

讲一个程序员如何副业月赚三万的真实故事

loonggg读完需要3分钟速读仅需 1 分钟大家好,我是你们的校长。我之前讲过,这年头,只要肯动脑,肯行动,程序员凭借自己的技术,赚钱的方式还是有很多种的。仅仅靠在公司出卖自己的劳动时...

上班一个月,后悔当初着急入职的选择了

最近有个老铁,告诉我说,上班一个月,后悔当初着急入职现在公司了。他之前在美图做手机研发,今年美图那边今年也有一波组织优化调整,他是其中一个,在协商离职后,当时捉急找工作上班,因为有房贷供着,不能没有收入来源。所以匆忙选了一家公司,实际上是一个大型外包公司,主要派遣给其他手机厂商做外包项目。**当时承诺待遇还不错,所以就立马入职去上班了。但是后面入职后,发现薪酬待遇这块并不是HR所说那样,那个HR自...

总结了 150 余个神奇网站,你不来瞅瞅吗?

原博客再更新,可能就没了,之后将持续更新本篇博客。

副业收入是我做程序媛的3倍,工作外的B面人生是怎样的?

提到“程序员”,多数人脑海里首先想到的大约是:为人木讷、薪水超高、工作枯燥…… 然而,当离开工作岗位,撕去层层标签,脱下“程序员”这身外套,有的人生动又有趣,马上展现出了完全不同的A/B面人生! 不论是简单的爱好,还是正经的副业,他们都干得同样出色。偶尔,还能和程序员的特质结合,产生奇妙的“化学反应”。 @Charlotte:平日素颜示人,周末美妆博主 大家都以为程序媛也个个不修边幅,但我们也许...

MySQL数据库面试题(2020最新版)

文章目录数据库基础知识为什么要使用数据库什么是SQL?什么是MySQL?数据库三大范式是什么mysql有关权限的表都有哪几个MySQL的binlog有有几种录入格式?分别有什么区别?数据类型mysql有哪些数据类型引擎MySQL存储引擎MyISAM与InnoDB区别MyISAM索引与InnoDB索引的区别?InnoDB引擎的4大特性存储引擎选择索引什么是索引?索引有哪些优缺点?索引使用场景(重点)...

如果你是老板,你会不会踢了这样的员工?

有个好朋友ZS,是技术总监,昨天问我:“有一个老下属,跟了我很多年,做事勤勤恳恳,主动性也很好。但随着公司的发展,他的进步速度,跟不上团队的步伐了,有点...

我入职阿里后,才知道原来简历这么写

私下里,有不少读者问我:“二哥,如何才能写出一份专业的技术简历呢?我总感觉自己写的简历太烂了,所以投了无数份,都石沉大海了。”说实话,我自己好多年没有写过简历了,但我认识的一个同行,他在阿里,给我说了一些他当年写简历的方法论,我感觉太牛逼了,实在是忍不住,就分享了出来,希望能够帮助到你。 01、简历的本质 作为简历的撰写者,你必须要搞清楚一点,简历的本质是什么,它就是为了来销售你的价值主张的。往深...

程序员写出这样的代码,能不挨骂吗?

当你换槽填坑时,面对一个新的环境。能够快速熟练,上手实现业务需求是关键。但是,哪些因素会影响你快速上手呢?是原有代码写的不够好?还是注释写的不够好?昨夜...

离职半年了,老东家又发 offer,回不回?

有小伙伴问松哥这个问题,他在上海某公司,在离职了几个月后,前公司的领导联系到他,希望他能够返聘回去,他很纠结要不要回去? 俗话说好马不吃回头草,但是这个小伙伴既然感到纠结了,我觉得至少说明了两个问题:1.曾经的公司还不错;2.现在的日子也不是很如意。否则应该就不会纠结了。 老实说,松哥之前也有过类似的经历,今天就来和小伙伴们聊聊回头草到底吃不吃。 首先一个基本观点,就是离职了也没必要和老东家弄的苦...

HTTP与HTTPS的区别

面试官问HTTP与HTTPS的区别,我这样回答让他竖起大拇指!

程序员毕业去大公司好还是小公司好?

虽然大公司并不是人人都能进,但我仍建议还未毕业的同学,尽力地通过校招向大公司挤,但凡挤进去,你这一生会容易很多。 大公司哪里好?没能进大公司怎么办?答案都在这里了,记得帮我点赞哦。 目录: 技术氛围 内部晋升与跳槽 啥也没学会,公司倒闭了? 不同的人脉圈,注定会有不同的结果 没能去大厂怎么办? 一、技术氛围 纵观整个程序员技术领域,哪个在行业有所名气的大牛,不是在大厂? 而且众所...

程序员为什么千万不要瞎努力?

本文作者用对比非常鲜明的两个开发团队的故事,讲解了敏捷开发之道 —— 如果你的团队缺乏统一标准的环境,那么即使勤劳努力,不仅会极其耗时而且成果甚微,使用...

为什么程序员做外包会被瞧不起?

二哥,有个事想询问下您的意见,您觉得应届生值得去外包吗?公司虽然挺大的,中xx,但待遇感觉挺低,马上要报到,挺纠结的。

当HR压你价,说你只值7K,你该怎么回答?

当HR压你价,说你只值7K时,你可以流畅地回答,记住,是流畅,不能犹豫。 礼貌地说:“7K是吗?了解了。嗯~其实我对贵司的面试官印象很好。只不过,现在我的手头上已经有一份11K的offer。来面试,主要也是自己对贵司挺有兴趣的,所以过来看看……”(未完) 这段话主要是陪HR互诈的同时,从公司兴趣,公司职员印象上,都给予对方正面的肯定,既能提升HR的好感度,又能让谈判气氛融洽,为后面的发挥留足空间。...

面试阿里p7,被按在地上摩擦,鬼知道我经历了什么?

面试阿里p7被问到的问题(当时我只知道第一个):@Conditional是做什么的?@Conditional多个条件是什么逻辑关系?条件判断在什么时候执...

终于懂了TCP和UDP协议区别

终于懂了TCP和UDP协议区别

无代码时代来临,程序员如何保住饭碗?

编程语言层出不穷,从最初的机器语言到如今2500种以上的高级语言,程序员们大呼“学到头秃”。程序员一边面临编程语言不断推陈出新,一边面临由于许多代码已存在,程序员编写新应用程序时存在重复“搬砖”的现象。 无代码/低代码编程应运而生。无代码/低代码是一种创建应用的方法,它可以让开发者使用最少的编码知识来快速开发应用程序。开发者通过图形界面中,可视化建模来组装和配置应用程序。这样一来,开发者直...

面试了一个 31 岁程序员,让我有所触动,30岁以上的程序员该何去何从?

最近面试了一个31岁8年经验的程序猿,让我有点感慨,大龄程序猿该何去何从。

大三实习生,字节跳动面经分享,已拿Offer

说实话,自己的算法,我一个不会,太难了吧

程序员垃圾简历长什么样?

已经连续五年参加大厂校招、社招的技术面试工作,简历看的不下于万份 这篇文章会用实例告诉你,什么是差的程序员简历! 疫情快要结束了,各个公司也都开始春招了,作为即将红遍大江南北的新晋UP主,那当然要为小伙伴们做点事(手动狗头)。 就在公众号里公开征简历,义务帮大家看,并一一点评。《启舰:春招在即,义务帮大家看看简历吧》 一石激起千层浪,三天收到两百多封简历。 花光了两个星期的所有空闲时...

《C语言函数速查》main()主函数

每一个C程序都必须有一main()函数, 可以根据自己的爱好把它放在程序的某个地方。有些程序员把它放在最前面, 而另一些程序员把它放在最后面, 无论放在哪个地方, 以下几点说明都是适合的。

Java岗开发3年,公司临时抽查算法,离职后这几题我记一辈子

前几天我们公司做了一件蠢事,非常非常愚蠢的事情。我原以为从学校出来之后,除了找工作有测试外,不会有任何与考试有关的事儿。 但是,天有不测风云,公司技术总监、人事总监两位大佬突然降临到我们事业线,叫上我老大,给我们组织了一场别开生面的“考试”。 那是一个风和日丽的下午,我翘着二郎腿,左手端着一杯卡布奇诺,右手抓着我的罗技鼠标,滚动着轮轴,穿梭在头条热点之间。 “淡黄的长裙~蓬松的头发...

大牛都会用的IDEA调试技巧!!!

导读 前天面试了一个985高校的实习生,问了他平时用什么开发工具,他想也没想的说IDEA,于是我抛砖引玉的问了一下IDEA的调试用过吧,你说说怎么设置断点...

面试官:你连SSO都不懂,就别来面试了

大厂竟然要考我SSO,卧槽。

终于,月薪过5万了!

来看几个问题想不想月薪超过5万?想不想进入公司架构组?想不想成为项目组的负责人?想不想成为spring的高手,超越99%的对手?那么本文内容是你必须要掌握的。本文主要详解bean的生命...

我说我懂多线程,面试官立马给我发了offer

不小心拿了几个offer,有点烦

自从喜欢上了B站这12个UP主,我越来越觉得自己是个废柴了!

不怕告诉你,我自从喜欢上了这12个UP主,哔哩哔哩成为了我手机上最耗电的软件,几乎每天都会看,可是吧,看的越多,我就越觉得自己是个废柴,唉,老天不公啊,不信你看看…… 间接性踌躇满志,持续性混吃等死,都是因为你们……但是,自己的学习力在慢慢变强,这是不容忽视的,推荐给你们! 都说B站是个宝,可是有人不会挖啊,没事,今天咱挖好的送你一箩筐,首先啊,我在B站上最喜欢看这个家伙的视频了,为啥 ,咱撇...

代码注释如此沙雕,会玩还是你们程序员!

某站后端代码被“开源”,同时刷遍全网的,还有代码里的那些神注释。 我们这才知道,原来程序员个个都是段子手;这么多年来,我们也走过了他们的无数套路… 首先,产品经理,是永远永远吐槽不完的!网友的评论也非常扎心,说看这些代码就像在阅读程序员的日记,每一页都写满了对产品经理的恨。 然后,也要发出直击灵魂的质问:你是尊贵的付费大会员吗? 这不禁让人想起之前某音乐app的穷逼Vip,果然,穷逼在哪里都是...

立即提问
相关内容推荐