草庐IT

method_idx

全部标签

Java 反射 : How can I get the all getter methods of a java class and invoke them

我写了一个有很多getter的java类..现在我想获取所有getter方法并在某个时候调用它们..我知道有诸如getMethods()或getMethod(Stringname,Class...parameterTypes)之类的方法,但我只想得到真正的setter/getter......,使用正则表达式?谁能告诉我?谢谢! 最佳答案 不要使用正则表达式,使用Introspector:for(PropertyDescriptorpropertyDescriptor:Introspector.getBeanInfo(yourCla

spring - Spring 中的 'init-method' 之类的东西,但在注入(inject)依赖项后调用?

这太疯狂了...使用Spring已经有一段时间了,但找不到像在注入(inject)所有依赖项后调用的“init-method”之类的东西。我看到了BeanPostProcessor东西,但我正在寻找一种轻量且非侵入性的东西,它不会将我的bean与Spring耦合。就像init方法一样! 最佳答案 在Spring2.5及更高版本中,如果对象需要在初始化时调用回调方法,则可以使用@PostConstruct注释对该方法进行注释。例如:publicclassMyClass{@PostConstructpublicvoidmyMethod(

java - SONAR 提示 Make the enclosure method "static"or remove this set

我的程序中有以下代码,在将其与Maven集成后,我正在运行SonarQube5以对其进行代码质量检查。但是,Sonar要求将封闭方法设为“静态”或删除此集合。方法是setApplicationContext。如何消除此错误?为什么会出现这个错误?publicclassSharedContextimplementsApplicationContextAware{publicstaticfinalStringREPORT_ENGINE_FACTORY="reportEngineFactory";privatestaticApplicationContextapplicationContex

Spring:注解等价于 security:authentication-manager 和 security:global-method-security

在XML配置中,我可以使用security命名空间来启用对安全性的支持,例如:我尝试使用没有XML的Spring,只有@Configuration类。与上述XML示例类似的配置的纯Java等价物是什么? 最佳答案 编辑:2013年12月SpringSecurity3.2wasreleased和JavaConfigurationwasimplemented,所以上面的XML大致相当于:@Configuration@EnableGlobalMethodSecurity(prePostEnabled=true)publicclassSec

Spring Data JPA Repository Method Query 与like?

在Spring-dataJPA中,有没有办法创建一个本质上是通过like搜索的方法查询?我有以下方法查询publicMakeModelfindByModelIgnoreCase(Stringmodel);我真正想要的是一个like表达式。我只需要创建一个Criteria或一个@Query注释吗?我要求太多了吗?//StupidexampleofwhatIwanttobeabletodopublicMakeModelfindByFuzzyModelIgnoreCase(Stringmodel);真的,我猜它的核心是,我想做一个表格搜索。我在SpringData下使用Hibernate,所

java - Struts2 + Spring Security 2.06 : Valuestack is null when attempting to use @Secured on an Action method

在开始之前,我必须说我找到的最接近的答案是here但老实说,我真的不明白那里发生了什么。我正在使用带有自定义身份验证提供程序和访问决策管理器的Struts2+SpringSecurity2.06,以消除对“ROLE_”前缀的需要。我的applicationContext-security.xml看起来像这样:我的web.xml的相关部分:springSecurityFilterChainorg.springframework.web.filter.DelegatingFilterProxystruts2org.apache.struts2.dispatcher.ng.filter.St

spring - 从 ProceedingJoinPoint 获取 java.lang.reflect.Method?

这个问题很简短:有没有办法从apsectjProceedingJoinPoint获取Method对象?目前我正在做Class[]parameterTypes=newClass[joinPoint.getArgs().length];Object[]args=joinPoint.getArgs();for(inti=0;i但我不认为这是要走的路…… 最佳答案 您的方法没有错,但有更好的方法。您必须转换为MethodSignatureMethodSignaturesignature=(MethodSignature)joinPoint.

Spring @PostConstruct 与 init-method 属性

在SpringXML配置中使用@PostConstruct注解和声明与init-method相同的方法有什么区别吗? 最佳答案 实际上,我认为没有任何区别,但它们的工作方式有优先级。@PostConstruct、init-method是BeanPostProcessors。@PostConstruct是JSR-250注释,而init-method是Spring拥有初始化方法的方式。如果您有@PostConstruct方法,则会在调用初始化方法之前首先调用它。如果您的bean实现InitializingBean并覆盖afterProp

php mysqli_connect : authentication method unknown to the client [caching_sha2_password]

我正在使用phpmysqli_connect登录MySQL数据库(都在本地主机上)这是mysql.user表:MySQL服务器ini文件:[mysqld]#Thedefaultauthenticationplugintobeusedwhenconnectingtotheserverdefault_authentication_plugin=caching_sha2_password#default_authentication_plugin=mysql_native_password在MySQL服务器ini文件中使用caching_sha2_password,根本不可能使用user1或

android - java.lang.NullPointerException : Attempt to invoke virtual method 'float android.view.InputDevice$MotionRange.getMin()' 异常

我每次点击Widget时都会收到以下错误:java.lang.NullPointerException:Attempttoinvokevirtualmethod'floatandroid.view.InputDevice$MotionRange.getMin()'onanullobjectreference我切换到另一个项目并收到相同的错误,错误发生在TextField、按钮和GridList的项目上。我认为这可能是sdk中的一个错误Flutter:1.2.1Dart:2.2.0我升级了flutter,现在收到了。完整的日志是:ShuttingdownVME/AndroidRuntim