腾讯云
开发者社区
文档
建议反馈
控制台
首页
学习
活动
专区
工具
TVP
最新优惠活动
文章/答案/技术大牛
搜索
搜索
关闭
发布
登录/注册
精选内容/技术社群/优惠产品,
尽在小程序
立即前往
文章
问答
(9999+)
视频
沙龙
4
回答
如何
使用
Spring
在
Helper
类
中
获取
自动
连接
的
bean
java
、
spring
、
spring-mvc
、
spring-boot
、
dependency-injection
我想知道,
在
helper
类
中
获取
bean
的
最好方法是什么,因为你不能在那里
使用
@Autowired。我现在做
的
是
在
@Service/@Component/...然后将构造函数
中
的
bean
传递给
helper
类
。我不认为这是正确
的
方式,因为可能有太多
的
事情要通过。 做这件事<e
浏览 37
提问于2017-08-13
得票数 3
回答已采纳
2
回答
使用
构造函数args初始化
bean
- WebApplicationContext与ClassPathApplicationContext
java
、
spring
、
dependency-injection
、
applicationcontext
同时
使用
ClassPathXmlApllicationContext和WebApplicationContext实例化applicationContext.xml上
的
bean
定义。
使用
前一种方法时,
bean
会按预期返回,但
使用
后一种方法WebApplicationContext时,我会得到一个空值。
浏览 0
提问于2014-05-09
得票数 0
1
回答
JavaConfig
Spring
使所有应用程序都可以
使用
beans
java
、
spring
我有一个带有main方法
的
jar。我创建了一个带有@Configuration注释
的
java配置。+env+".properties"));我试图在其中注入
bean
的
类
(这里真的需要@组件吗?)Component@Autowired
浏览 4
提问于2017-01-25
得票数 0
3
回答
@Autowired不会在构造函数
中
创建成员
java
、
spring
我有一个从上下文创建
的
bean
,然后创建一个
自动
连接
的
成员:public class FileDownloadService extends WFWFileDownloadService{ ConfigurationManager configurationManager;FileDownloadServicefileDownloadService = new FileDo
浏览 0
提问于2013-04-14
得票数 0
回答已采纳
1
回答
在
Spring
引导
中
启动应用程序时从数据库
获取
全局值
spring
、
hibernate
、
jpa
我正在编写一个
Spring
Boot / JPA应用程序。我有一些需要对整个应用程序可见
的
值,这些值位于数据库
中
。我应该从哪里
获取
这些值?我应该在包含@SpringBootApplication
的
类
中
获取
它们吗?
如何
使其对应用程序可见?我读到
在
Spring
中
,我们可以
使用
@
Bean
类
来保存全局变量。那么,我是否必须将
浏览 1
提问于2015-04-10
得票数 1
1
回答
在
Spring
框架
中
自动
装配到底是做什么
的
?
spring
、
jakarta-ee
大家好,我是newbee to Springs framework,我只是想知道
在
Spring
框架
中
自动
装配到底是做什么
的
?
浏览 1
提问于2013-07-02
得票数 0
3
回答
Spring
:
自动
毛豆为空
java
、
spring
、
spring-mvc
、
nullpointerexception
、
autowired
我正在开发一个
Spring
应用程序,在这个应用程序
中
,我正在
自动
处理一个字段,但是它被设置为NULL。我在网上检查了相同
的
问题解决方案,正如他们所描述
的
,我不应该在工作时创建
类
的
新实例,而应该从
spring
中
获得它。我也试过了,但是它总是抱怨资源找不到。/WEB-INF/
spring
/root-context.xml"); GoogleAuthorization
浏览 4
提问于2015-07-08
得票数 1
回答已采纳
1
回答
当在
Spring
中
使用
@限定符时,我
如何
@Autowire到扩展
类
?
spring
、
spring-boot
、
annotations
我
的
目标是不触及服务或帮助
类
。我
的
想法是,通过给ExtHelper赋予与
Helper
相同
的
bean
名,
Spring
将
自动
将ExtHelper实现转换为Service而不是
Helper
。 我看到
的
结果好坏参半。如果ExtHelper包括
在
我
的
pom后帮助,它
的
工作正常。但在此之前,我得到了一个ConflictingBeanDefinitionException。我理
浏览 1
提问于2019-05-10
得票数 1
2
回答
如何
在
bean
定义方法
中
获取
spring
bean
java
、
spring
、
javabeans
我有一个java配置,ServiceB依赖于ServiceA:ServiceA getServiceA() { return new ServiceA(); }ServiceB我将@ScanPackage添加到配置
中
并注释ServiceA:class ServiceA { .. } 现在
如何
声明方法getServiceB()?
浏览 2
提问于2017-02-09
得票数 1
回答已采纳
2
回答
为什么下面的代码不适用于
自动
连线
spring
我有一个像这样
的
课程 @Autowired} 我发现b不是
自动
连接
的
我已经做过<context:component-scanbase-package="*">了还有什么遗漏
的
吗?
浏览 1
提问于2011-05-04
得票数 1
回答已采纳
1
回答
Ehcache和
spring
引导器不工作
spring
、
caching
、
ehcache
、
terracotta
这里我
使用
与
spring
集成
的
ehcache。但问题是,我无法将依赖项
连接
到我
的
cacheloader实现
中
。“
自动
头发”、“资源”、“可配置”似乎都不起作用。很明显,cacheloader实例化不是由
Spring
容器完成
的
,但是有什么方法可以将
spring
创建
的
cacheloader实例注入cachemanager并引导它呢?下面是我
的
实现细节。" listenFor=
浏览 3
提问于2014-01-01
得票数 1
1
回答
我可以将grails服务
自动
连接
到java src
类
吗?
grails
如何
从位于grails-app SRC文件夹
中
的
java
类
自动
连接
Grails服务?
浏览 3
提问于2015-08-13
得票数 0
3
回答
spring
非托管对象
的
自动
装配
java
、
spring
、
dependency-injection
、
autowired
我想知道
如何
在不受
spring
应用程序上下文管理
的
java对象
中
自动
连接
sprig
bean
。我已经创建了一个
类
的
实例,但是随后
的
自动
装配对象是空
的
。例如。String userName, String b){}我
浏览 2
提问于2016-08-04
得票数 0
2
回答
如何
扩展带有@ConditionalOnMissingBean注释
的
默认
bean
?
java
、
spring
、
javabeans
、
autowired
、
spring-ioc
我研究了this question,以了解“默认”
bean
是
如何
在
Spring
中
实现
的
。
在
我
的
项目的父模块中有一个用@ConditionalOnMissingBean注释
的
bean
。我想
使用
这个
bean
并扩展它
的
功能,而不是返回一个全新
的
实例。示例 // in parent module @Conditional
浏览 20
提问于2019-09-11
得票数 0
2
回答
为什么这个简单
的
spring
启动应用程序会给出一个空指针异常?
java
、
spring-boot
、
dependency-injection
、
maven-3
当我试图调用
自动
连接
的
对象上
的
方法时,我一直得到一个空指针异常,我不知道为什么。我做每件事都是照章办事。(
在
本例
中
为
spring
)。SpringApplication.run(BasicApplication.class, args); }配置文件(我知道有未
使用
的
导入*若要更改此模板文件,请选择“工具”|“模板”,然后在编辑器
中
打开模板。pu
浏览 0
提问于2017-08-01
得票数 0
3
回答
自动
装配似乎失败了
java
、
spring
、
autowired
我对此视而不见,所以也许你们
中
的
一些人看到了什么不对劲。> </
bean
> calendarRepository.create(new CalendarItem("TEST"));} 这是我得到
的
堆栈跟踪
的
一部分com.sun.jersey.server.impl.model.method.dis
浏览 3
提问于2014-12-23
得票数 0
回答已采纳
3
回答
在
托管
bean
外部访问
Spring
web应用程序数据库
spring
、
web-applications
、
database-connection
、
managed-bean
在
我
的
web应用程序
中
,我有一个applicationContext.xml,它定义了
bean
、数据库
连接
参数等。虽然我可以
在
pojo
类
中
使用
托管
bean
(
使用
服务和daos)进行所需
的
操作,但我不能
使用
这些服务和托管
bean
。有没有一种方法可以
使用
应用程序上下文中
的
参数从pojo访问数据库?我看到
的
每个示例都
浏览 2
提问于2014-03-11
得票数 1
2
回答
Spring
注解@
自动
连接
的
内部方法
java
、
spring
、
dependency-injection
@Autowired可以与构造函数、设置器和
类
变量一起
使用
。 @Autowired }如果这是不可能
的
,(我
使用
了
Spring
4。)
浏览 0
提问于2014-09-01
得票数 16
回答已采纳
3
回答
Spring
-servlet.xml beans访问
spring
、
spring-mvc
在
Spring
中
,我通常
使用
getBean()方法访问
bean
。例如:<?xml version="1.0" encoding="UTF-8"?> <
bean
id="MyClass" class="ioc.beans.M
浏览 2
提问于2013-04-18
得票数 0
回答已采纳
3
回答
弹簧
自动
转向器及原型范围
java
、
spring
、
annotations
、
inversion-of-control
我有一个名为Bar
的
类
,其注释如下:@Configurable(autowire = Autowire.BY_TYPE)@Autowired(required = true)
在
spring
配置
中
,我有一个Foo
类
的
bean
。如果这个
bean
是用scope="prototype"定义
的
,它就不能工作,我得到了以下异常: NoSuc
浏览 3
提问于2012-03-22
得票数 17
回答已采纳
点击加载更多
扫码
添加站长 进交流群
领取专属
10元无门槛券
手把手带您无忧上云
相关
资讯
MyBatis与Spring 整合
SpringBoot常用注解大全
Spring Boot 注解大全,真是太全了!
自己实现Spring
Spring|一文带你掌握IOC技术
热门
标签
更多标签
云服务器
ICP备案
实时音视频
对象存储
即时通信 IM
活动推荐
运营活动
广告
关闭
领券