Comments (8)
估计是因为是webapplication初始化而不是rootapplication初始化的原因。web.xml在配置时,将配置文件配置在dispatcherservlet中初始化了,这样子避免了一个bean 使用范围的问题
from seckill.
我不是太明白你说的意思。其实我就是想让bean在服务启动的时候就初始化,不知道哪里出了问题
from seckill.
这样子,用org.springframework.web.context.ContextLoaderListener这个监听器加载dao和service,web在servlet中加载试试。
from seckill.
http://blog.csdn.net/hengyunabc/article/details/47072637 记得结果告诉我下。。
from seckill.
好的,谢谢先
from seckill.
http://codingxiaxw.cn/2016/11/11/39-Spring/ 看看我的这篇文章第四节“创建的细节”,通过在xml文件中设置bean的scope属性,可以控制bean在服务启动的时候就初始化或是我们需要使用这个pojo对象的时候再初始化
from seckill.
@codingXiaxw 可能是我没有描述清楚问题,为了测试,我在controller类加了默认构造方法打印一句话,服务启动后并没有打印这句话,这是问题现象;
问题解决了,需要在web.xml里面配置DispatcherServlet加上<load-on-startup>1</load-on-startup>
加上后,启动容器后就会打印controller默认构造方法那句话了。老师的列子中没有加哈。
我在Intellij idea下测试
@281613520
from seckill.
可以的小伙子
from seckill.
Related Issues (20)
- /seckill/list 404 HOT 3
- 关于注解映射器和适配器的说法有误?
- 大神可以把sql的建表语句发一下吗,本地运行说找不到表
- 请问下大佬 Protostuff 如何序列化Class<T> ?
- SeckillServiceImpl.exportSeckillUrl在并发高的时候会缓存击穿吧 HOT 4
- 好像是慕课网的教程,您是慕课网那位讲课老师吗 HOT 1
- 请教一个问题,关于分布式锁的 HOT 2
- 数据库没有啊,你们怎么运行的啊 HOT 2
- 运行不了 HOT 1
- 为什么总是空指针异常啊
- 并发测试 HOT 1
- DDL issue
- 连接被拒绝是什么问题
- 数据库连接问题 HOT 1
- 部署后可以打开 helloword页面,但打不开list页面 HOT 2
- 运行
- Redis缓存中的数据没变化
- 创建success_killed表没有设置create_time自动更新 HOT 2
- 秒杀超卖现象 HOT 2
- 存储过程seckill.sql有点问题
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from seckill.