Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

楼主的项目在eclipse和IDEA里面都无法运行,请问该怎么配置呢 #16

Open
wzunique opened this issue Jan 20, 2018 · 10 comments

Comments

@wzunique
Copy link

一月 20, 2018 12:18:27 下午 org.apache.catalina.core.StandardContext listenerStart
严重: Exception sending context initialized event to listener instance of class ssm.blog.listener.InitBloggerData
java.lang.NullPointerException
at ssm.blog.listener.InitBloggerData.contextInitialized(InitBloggerData.java:38)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:5003)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5517)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1574)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1564)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)

一月 20, 2018 12:18:27 下午 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, 2018 12:18:27 下午 org.apache.catalina.core.StandardContext startInternal
严重: Context [/Blog] startup failed due to previous errors
一月 20, 2018 12:18:27 下午 org.apache.catalina.core.ApplicationContext log
信息: Closing Spring root WebApplicationContext
2018-01-20 12:18:27,624 [localhost-startStop-1] INFO [org.springframework.web.context.support.XmlWebApplicationContext] - Closing Root WebApplicationContext: startup date [Sat Jan 20 12:18:25 CST 2018]; root of context hierarchy
2018-01-20 12:18:27,624 [localhost-startStop-1] DEBUG [org.springframework.beans.factory.support.DefaultListableBeanFactory] - Returning cached instance of singleton bean 'sqlSessionFactory'
2018-01-20 12:18:27,625 [localhost-startStop-1] DEBUG [org.springframework.beans.factory.support.DefaultListableBeanFactory] - Returning cached instance of singleton bean 'lifecycleProcessor'
2018-01-20 12:18:27,625 [localhost-startStop-1] DEBUG [org.springframework.beans.factory.support.DefaultListableBeanFactory] - Destroying singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@a502c9: defining beans [blogAdminController,bloggerAdminController,blogTypeAdminController,commentAdminController,linkAdminController,systemAdminController,blogController,bloggerController,commentController,indexController,initBloggerData,bloggerService,blogService,blogTypeService,commentService,linkService,org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,org.springframework.context.event.internalEventListenerProcessor,org.springframework.context.event.internalEventListenerFactory,dataSource,sqlSessionFactory,org.mybatis.spring.mapper.MapperScannerConfigurer#0,transactionManager,myRealm,securityManager,shiroFilter,lifecycleBeanPostProcessor,org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator#0,org.apache.shiro.spring.security.interceptor.AuthorizationAttributeSourceAdvisor#0,txAdvice,org.springframework.aop.config.internalAutoProxyCreator,pointCut,org.springframework.aop.support.DefaultBeanFactoryPointcutAdvisor#0,org.springframework.context.annotation.ConfigurationClassPostProcessor.importAwareProcessor,org.springframework.context.annotation.ConfigurationClassPostProcessor.enhancedConfigurationProcessor,blogDao,bloggerDao,blogTypeDao,commentDao,linkDao]; root of factory hierarchy
2018-01-20 12:18:27,633 [localhost-startStop-1] DEBUG [org.springframework.beans.factory.support.DefaultListableBeanFactory] - Retrieved dependent beans for bean '(inner bean)#12817cf': [txAdvice]
2018-01-20 12:18:27,633 [localhost-startStop-1] DEBUG [org.springframework.beans.factory.support.DisposableBeanAdapter] - Invoking destroy method 'close' on bean with name 'dataSource'
2018-01-20 12:18:27,636 [localhost-startStop-1] INFO [com.alibaba.druid.pool.DruidDataSource] - {dataSource-1} closed
一月 20, 2018 12:18:27 下午 org.apache.catalina.loader.WebappClassLoader clearReferencesJdbc
严重: The web application [/Blog] 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.
一月 20, 2018 12:18:27 下午 org.apache.catalina.loader.WebappClassLoader clearReferencesJdbc
严重: The web application [/Blog] 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.
一月 20, 2018 12:18:27 下午 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
严重: The web application [/Blog] appears to have started a thread named [Abandoned connection cleanup thread] but has failed to stop it. This is very likely to create a memory leak.
一月 20, 2018 12:18:27 下午 org.apache.coyote.AbstractProtocol start
信息: Starting ProtocolHandler ["http-bio-8080"]
一月 20, 2018 12:18:27 下午 org.apache.coyote.AbstractProtocol start
信息: Starting ProtocolHandler ["ajp-bio-8089"]
一月 20, 2018 12:18:27 下午 org.apache.catalina.startup.Catalina start
信息: Server startup in 4203 ms

@weenhall
Copy link

把InitBloggerData中第二个方法中的内容注释掉

@wzunique
Copy link
Author

wzunique commented Mar 1, 2018

具体怎么弄?

@weenhall
Copy link

weenhall commented Mar 1, 2018

找到InitBloggerData这个类,第二个方法中的内容注释掉。跑不起来是因为该方法使用数据库时内存溢出

@wzunique
Copy link
Author

wzunique commented Mar 1, 2018

具体是注释哪里?

package ssm.blog.listener;

import java.util.List;

import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;

import ssm.blog.entity.Blog;
import ssm.blog.entity.BlogType;
import ssm.blog.entity.Blogger;
import ssm.blog.entity.Link;
import ssm.blog.service.BlogService;
import ssm.blog.service.BlogTypeService;
import ssm.blog.service.BloggerService;
import ssm.blog.service.LinkService;

@component
public class InitBloggerData implements ServletContextListener, ApplicationContextAware {

private static ApplicationContext applicationContext;

public void contextInitialized(ServletContextEvent sce) {
	System.out.println(applicationContext);
	//先获取servlet上下文
	ServletContext application = sce.getServletContext();
	
	//根据spring的上下文获取bloggerService这个bean
	BloggerService bloggerService = (BloggerService) applicationContext.getBean("bloggerService");
	//获取博主信息
	Blogger blogger = bloggerService.getBloggerData();
	//由于密码也获取到了,比较敏感,我们也不需要这个,所以把密码清空掉
	blogger.setPassword(null);
	//将博主信息存入application域中
	application.setAttribute("blogger", blogger);
	
	//同上,获取友情链接信息
	LinkService linkService = (LinkService) applicationContext.getBean("linkService");
	List<Link> linkList = linkService.getLinkData(); 
	application.setAttribute("linkList", linkList);
	
	//同上,获取博客类别信息
	BlogTypeService blogTypeService = (BlogTypeService) applicationContext.getBean("blogTypeService");
	List<BlogType> blogTypeList = blogTypeService.getBlogTypeData();
	application.setAttribute("blogTypeList", blogTypeList);
	
	//同上,获取博客信息,按照时间分类的
	BlogService blogService = (BlogService) applicationContext.getBean("blogService");
	List<Blog> blogTimeList = blogService.getBlogData();
	application.setAttribute("blogTimeList", blogTimeList);
}

public void contextDestroyed(ServletContextEvent sce) {
	// TODO Auto-generated method stub
	
}

public void setApplicationContext(ApplicationContext applicationContext) 
		throws BeansException {
	InitBloggerData.applicationContext = applicationContext;
}

}

@weenhall
Copy link

weenhall commented Mar 2, 2018

contextInitialized这个方法里面的内容注释掉

@wzunique
Copy link
Author

wzunique commented Mar 2, 2018

还是没有用
HTTP Status 404 - /

type Status report

message /

description The requested resource is not available.

Apache Tomcat/7.0.64

@weenhall
Copy link

weenhall commented Mar 2, 2018

链接: https://pan.baidu.com/s/1nw0R2rB 密码: 8pc7
用这个,先把数据导进去

@wzunique
Copy link
Author

wzunique commented Mar 5, 2018

这个java1234的blog你试成功了吗?

@weenhall
Copy link

weenhall commented Mar 6, 2018

可以运行啊,你没调试好吧

@changjiliao
Copy link

突然发现这个没有注册功能

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants