我有一个实用程序方法,遍历各种类并递归检索字段.我想检查该字段是否为Collection.以下是一些示例代码:
void myMethod(Class<?> classToCheck)
Field[] fields = classToCheck.getDeclaredFields();
for(Field field:fields)
{
// check if field if a Collection<?>
}
Run Code Online (Sandbox Code Playgroud)
在此先感谢您的帮助.
我是ldap的新手,我正在尝试一下我认为是一个简单的例子来测试一个有人已经设置用于测试的ldap实例的spring ldap模块.
有关我正在使用的ldap实例的详细信息,请访问:http: //blog.stuartlewis.com/2008/07/07/test-ldap-service/comment-page-3/
我使用了ldap浏览器/管理工具(Softerra LDAP Admin),我可以毫无问题地访问该目录.
当我使用java和spring-ldap(2.0.1)尝试它时,我得到上面提到的身份验证异常.在设置我自己的ldap实例以尝试进一步排除故障之前,我想在这里查看,以防有经验的人可以指出我错过的一些明显的东西.
以下是我使用的代码:
import org.springframework.ldap.core.LdapTemplate;
import org.springframework.ldap.core.support.LdapContextSource;
import java.util.List;
public class LdapTest {
public List<String> getListing() {
LdapTemplate template = getTemplate();
List<String> children = template.list("dc=testathon,dc=net");
return children;
}
private LdapTemplate getTemplate(){
LdapContextSource contextSource = new LdapContextSource();
contextSource.setUrl("ldap://ldap.testathon.net:389");
contextSource.setUserDn("cn=john");
contextSource.setPassword("john");
try {
contextSource.afterPropertiesSet();
} catch (Exception ex) {
ex.printStackTrace();
}
LdapTemplate template = new LdapTemplate();
template.setContextSource(contextSource);
return template;
}
public static void main(String[] args){
LdapTest sClient = new LdapTest();
List<String> children = sClient.getListing(); …Run Code Online (Sandbox Code Playgroud) 第一次尝试springboot,但我无法启动它.我使用了示例应用程序:https://github.com/spring-guides/gs-spring-boot.git 我还修改了使用嵌入式jetty而不是tomcat但仍然没有成功.
我得到的例外是:org.springframework.context.ApplicationContextException:无法启动嵌入式容器; 嵌套异常是java.lang.IllegalArgumentException:资源位置不能为null.
这是在MacOSX上.
编辑:我已经确认这是一个环境问题.我可以在linux(fedora)VM中启动应用程序,但无论出于何种原因,我在Mac上遇到了这个问题.不确定是否有其他人遇到这个并且有任何可能导致此问题的线索.
编辑2:因此,这似乎是尝试默认配置ssl的问题.我不确定为什么会这样,因为我没有在任何地方指明这一点; 所以现在我的问题是,如何在spring-boot中禁用https?
mvn -version
Apache Maven 3.2.5 (12a6b3acb947671f09b81f49094c53f426d8cea1; 2014-12-14T09:29:23-08:00)
Maven home: /usr/local/Cellar/maven/3.2.5/libexec
Java version: 1.8.0_25, vendor: Oracle Corporation
Java home: /Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "mac os x", version: "10.10.5", arch: "x86_64", family: "mac"
Run Code Online (Sandbox Code Playgroud)
任何帮助表示赞赏.
org.springframework.context.ApplicationContextException: Unable to start embedded container; nested exception is java.lang.IllegalArgumentException: Resource location must not be null
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:137) ~[spring-boot-1.4.2.RELEASE.jar!/:1.4.2.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:536) ~[spring-context-4.3.4.RELEASE.jar!/:4.3.4.RELEASE]
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122) ~[spring-boot-1.4.2.RELEASE.jar!/:1.4.2.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:761) [spring-boot-1.4.2.RELEASE.jar!/:1.4.2.RELEASE]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:371) [spring-boot-1.4.2.RELEASE.jar!/:1.4.2.RELEASE]
at …Run Code Online (Sandbox Code Playgroud) 各位大家好,感谢您的帮助.
我遇到一个问题,Spring无法自动装配ArrayBlockingQueue类型的参数化成员变量.
这是java代码:
@Controller
public class SomeController
{
@Autowired
private ArrayBlockingQueue<SomeCustomType> myQueue;
}
Run Code Online (Sandbox Code Playgroud)
并在spring配置xml中:
<bean id="myQueue" class="java.util.concurrent.ArrayBlockingQueue">
<constructor-arg value="10"/>
</bean>
Run Code Online (Sandbox Code Playgroud)
为ArrayBlockingQueue指定类型(SomeCustomType)似乎会混淆spring无法找到匹配并且不执行自动装配.
有关如何使其工作的任何想法?我知道我可以创建我自己的包装类(围绕ArrayBlockingQueue),这个类没有参数化但我宁愿不知道是否有更好的方法来解决这个问题.
我有一个基本菜单,一些菜单项有子菜单.我对wordpress的经验很少,没有时间深入研究细节.所以我的问题是,当用户导航到其中一个子菜单页面时,突出显示顶部菜单项的最简单方法是什么.(我尝试使用javascript和纯css按元素id设置color属性,并使用"current-cat-parent"类但不起作用).
任何帮助是极大的赞赏.
注意:我使用的是一个名为chameleon的主题.
有没有一种简单的方法来模拟这个调用:
objectA.getB().getC();
Run Code Online (Sandbox Code Playgroud)
现在我这样做的方式是:
A mockA = EasyMock.createMock(A.class);
B mockB = EasyMock.createMock(B.class);
C mockC = EasyMock.createMock(C.class);
expect(mockA.getB()).andReturn(mockB);
expect(mockB.getC()).andReturn(mockC);
Run Code Online (Sandbox Code Playgroud)
这有点矫枉过正,因为我只关心获得 mockC。有没有更简单的方法来做到这一点?
我正在使用restTemplate对servlet进行rquest,该servlet返回json中对象的非常简单的表示.
{
"id":"SomeID"
"name":"SomeName"
}
Run Code Online (Sandbox Code Playgroud)
我有一个带有这两个字段的DTO以及相应的setter和getter.我想知道的是如何使用该json响应创建对象而无需"解析"响应.
我有一个maven项目,需要在命令行设置属性(-Dmy.property = val).我需要做的是将该字符串转换为全部大写字母,因为该属性用于通过maven-resources-plugin在多个文件中替换字符串.最简单的方法是什么?
我有一个页面,显示一堆使用 http 检索的图像的缩略图。我使用 ng-repeat 来遍历数组并生成 html。
这很好用。
我还创建了一个自定义指令,将其作为属性绑定到 ng-repeat 生成的 img 元素。
这也很好用。
但是,当我尝试将数据传递到自定义指令的范围时,一切都会崩溃。数据绑定失败,ng-repeat 不会替换图像的 url,因此我最终得到 404,因为 url 无效。目前为止就差不多了。
非常感谢任何帮助,因为我对 Angular 完全陌生。
我的 HTML 模板:
<div class="portfolioContent">
<div class="row">
<div class="col-lg-3 col-md-4 col-sm-4 col-xs-6 col-padding" ng-repeat="gImg in gPhotos">
<div class="photoframe">
<img src="{{gImg.thumbnailUrl}}" url="{{gImg.imageUrl}}" image-gallery>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
和我的自定义指令:
myApp.directive('imageGallery',function(){
return {
restrict: 'A',
scope: {
url: '='
},
controller: function($scope){
console.log($scope.url);
}
}
Run Code Online (Sandbox Code Playgroud)
});
对于那里的Oracle专家来说,这应该是一个简单的问题.我有一个列,(例如ID NUMBER(10),我使用Oracle序列生成下一个值.根据这个:http://docs.oracle.com/cd/B28359_01/server.111/b28286/statements_6015 .htm 一个序列可以生成28位的最大值.我想知道的是当生成足够的序列以达到上面列的最大大小时会发生什么,并且在序列定义中我指定了CYCLE但是我没有指定一个MAXVALUE.Oracle是否以智能方式处理并从头开始,或者我是否必须指定Oracle将继续生成大于上述ID列中可存储的数字的数字?
java ×4
spring ×2
angularjs ×1
easymock ×1
json ×1
maven ×1
oracle11g ×1
reflection ×1
resttemplate ×1
spring-boot ×1
spring-ldap ×1
types ×1
wordpress ×1