我有我的Android应用程序的情况.场景是我正在使用一个视图页面适配器whering我有3个页面实际上是片段.我的问题是我想从对话活动更新这些.对话活动包含一个列表来自其onclick事件我想更新片段.
首先是有可能,如果是,请切入并帮助我.
干杯Gaurav
这是我的视图页面适配器
/*
* Copyright (C) 2012 Gaurav Rawat
*
*/
package com.punksrant.ifinddryday.adapter;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import com.punksrant.ifinddryday.fragment.AllFragment;
import com.punksrant.ifinddryday.fragment.HomeFragment;
import com.punksrant.ifinddryday.fragment.SynchFragment;
import com.punksrant.ifinddryday.utils.IFindDryDaysConstants;
import com.viewpagerindicator.TitleProvider;
public class ViewPagerAdapter extends FragmentPagerAdapter implements
TitleProvider {
private static String[] titles = IFindDryDaysConstants.titles;
public ViewPagerAdapter(FragmentManager fm) {
super(fm);
}
@Override
public String getTitle(int position) {
return titles[position % titles.length].toUpperCase();
}
@Override
public int getCount() {
return titles.length;
}
@Override
public Fragment getItem(int position) {
Fragment fragment;
switch (position) …
Run Code Online (Sandbox Code Playgroud) 我在大多数测试中都使用了hamcrest,但遇到了一个问题,它无法在对象图中测试一个级别的属性.我的测试用例的剪辑如下
final List<Foo> foos= fooRepository.findAll(spec);
assertThat(results, is(notNullValue()));
assertThat(results, hasItem(hasProperty("id.fooID1", equalTo("FOOID1"))));
Run Code Online (Sandbox Code Playgroud)
所以在这里我想检查是否在foos列表中我有一个属性id.fooID1 equla到FOOID1.这是我向下一级检查我的嵌套属性.这目前在hamcrest中工作并且我得到以下错误.
java.lang.AssertionError:
Expected: a collection containing hasProperty("id.fooID1", "FOOID1")
but: No property "id.fooID1"
at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:20)
at org.junit.Assert.assertThat(Assert.java:956)
at org.junit.Assert.assertThat(Assert.java:923)
Run Code Online (Sandbox Code Playgroud)
有关此问题的任何帮助或解决方法.
我正在使用黄瓜测试来测试我的弹簧启动应用程序启用了弹簧安全性.除了我运行我的测试套件黄瓜测试使用弹簧安全性的一些测试时,工作正常.
@WithMockUser(username = "BROWSER", roles =
{"BROWSER","ADMIN"})
Run Code Online (Sandbox Code Playgroud)
如果我将它们作为简单的junit测试以隔离方式运行,但在运行黄瓜测试步骤时失败,则这些测试确实有效.问题看起来像春天安全测试模拟行为在我用黄瓜测试运行时不会被应用.
我的黄瓜试运行班如下
@RunWith(Cucumber.class)
@CucumberOptions(features = "src/test/resources", monochrome = true, format =
{"pretty", "html:src/main/resources/static/cucumber"})
public class CucumberTests
{
}
Run Code Online (Sandbox Code Playgroud)
此外,我注意到通过Maven运行时的相同工作 <reuseForks>false</reuseForks>
.如果未选中此选项,则maven触发的测试用例运行也会失败.
UPDATE
AbstractIntegrationTest类所有测试都扩展
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = Services.class,loader = SpringApplicationContextLoader.class)
//@IntegrationTest
@WebIntegrationTest(randomPort = true)
public abstract class AbstractIntegrationTest {
Run Code Online (Sandbox Code Playgroud)
另一个不起作用的用例是使用这些注释是如下的黄瓜特征条件
@When("^I apply a GET on (.*)$")
@WithMockUser(username = "BROWSER", roles = { "BROWSER", "ADMIN" })
public void i_search_with_rsql(String query) throws Throwable {
result = mvc.perform(get(uri, query));
}
Run Code Online (Sandbox Code Playgroud)
任何帮助或解决方法.
嗨,我刚刚升级到春季启动1.3.0.RELEASE,并在运行相同时再次得到这个奇怪的错误
14:43:52.503 [main] INFO c.test.whf.service.HfServices - Starting up....
Exception in thread "main" java.lang.IllegalAccessError: tried to access method org.springframework.core.convert.support.DefaultConversionService.addCollectionConverters(Lorg/springframework/core/convert/converter/ConverterRegistry;)V from class org.springframework.boot.bind.RelaxedConversionService
at org.springframework.boot.bind.RelaxedConversionService.<init>(RelaxedConversionService.java:52)
at org.springframework.boot.bind.RelaxedDataBinder.modifyProperties(RelaxedDataBinder.java:148)
at org.springframework.boot.bind.RelaxedDataBinder.doBind(RelaxedDataBinder.java:128)
at org.springframework.validation.DataBinder.bind(DataBinder.java:715)
at org.springframework.boot.bind.PropertiesConfigurationFactory.doBindPropertiesToTarget(PropertiesConfigurationFactory.java:267)
at org.springframework.boot.bind.PropertiesConfigurationFactory.bindPropertiesToTarget(PropertiesConfigurationFactory.java:240)
at org.springframework.boot.context.config.ConfigFileApplicationListener.bindToSpringApplication(ConfigFileApplicationListener.java:220)
at org.springframework.boot.context.config.ConfigFileApplicationListener.postProcessEnvironment(ConfigFileApplicationListener.java:171)
at org.springframework.boot.context.config.ConfigFileApplicationListener.onApplicationEnvironmentPreparedEvent(ConfigFileApplicationListener.java:161)
at org.springframework.boot.context.config.ConfigFileApplicationListener.onApplicationEvent(ConfigFileApplicationListener.java:146)
at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:163)
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:136)
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:119)
at org.springframework.boot.context.event.EventPublishingRunListener.publishEvent(EventPublishingRunListener.java:111)
at org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:65)
at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:54)
at org.springframework.boot.SpringApplication.doRun(SpringApplication.java:315)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:295)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1112)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1101)
at com.wellmanage.whf.service.HfServices.main(HfServices.java:97)
Run Code Online (Sandbox Code Playgroud)
我的代码也没有其他变化,不确定是什么导致了这一点.
app类就像下面一样简单
SpringApplication.run(HfServices.class, args);
Run Code Online (Sandbox Code Playgroud)
请帮忙 ...
我正在按照手册https://docs.spring.io/spring-boot/docs/current/reference/html/deployment-install.html 中的步骤将打包的 spring boot jar 作为 init.d 服务运行。一切都很好,但唯一的问题是它无法从 conf 文件中获取道具。在我的设置中,jar 文件名为 FooApp.jar,并且 conf 文件在同一目录路径中也被命名为 FooApp.conf。此外,conf 文件的内容如下
JAVA_OPTS=-Xmx1024M -Xms512m -Xdebug -Xrunjdwp:transport=dt_socket,address=9001,server=y,suspend=n -Denv=test
RUN_ARGS=--aws.vpc.name=fooVpc--aws.stack.name=foo --info.app.version=<VERSION> --spring.profiles.active=default,test,aws
Run Code Online (Sandbox Code Playgroud)
如果 conf 文件的格式正确,以及为什么当应用程序 spring boot 作为 linux 服务运行时,它不会从应用程序 conf 文件中获取配置,你能帮我吗?
谢谢
嗨我正在使用spring数据休息,并且当我使用PagingAndSortingRepository时,我得到一个奇怪的问题,我得到的响应有一个_self链接,但是它也提供了同一个实体的重复链接hf:foo作为以下响应中的evindent.
dupicate links "self":{"href":" http:// localhost:8080/foos/8445 "}和"hf:foo":{"href":" http:// localhost:8080/foos/8445 "
curl http://localhost:8080/foos?page=0&size=1
{
"_links" : {
"first" : {
"href" : "http://localhost:8080/foos?page=0&size=1"
},
"prev" : {
"href" : "http://localhost:8080/foos?page=0&size=1"
},
"self" : {
"href" : "http://localhost:8080/foos"
},
"next" : {
"href" : "http://localhost:8080/foos?page=2&size=1"
},
"last" : {
"href" : "http://localhost:8080/foos?page=81&size=1"
}
},
"_embedded" : {
"hf:foos" : [ {
"name" : "comsi",
"_links" : {
"self" : {
"href" : "http://localhost:8080/foos/8445"
},
"hf:foo" : {
"href" : "http://localhost:8080/foos/8445"
} ] …
Run Code Online (Sandbox Code Playgroud) 嗨我有一个要求动态忽略spring数据休息响应中的实体字段[我知道它们可以通过使用@JsonIgnore注释以静态方式完成]理想情况下基于Spring安全角色.角色部分仍然是可管理的但是如何动态忽略json响应中的字段是一个挑战.经过一些分析和文档后,我认为杰克逊是要走的路,因为弹簧数据休息通过jackson模块和mixins提供jackson定制http://docs.spring.io/spring-data/rest/docs/current/reference/html /#customizing-sdr.custom-jackson-deserialization.
所以我认为在jackson api中它可以通过@jsonFilter来完成,然后在ObjectMapper编写对象时提供相同的内容[更多详细信息,请访问http://www.cowtowncoder.com/blog/archives/2011/09/entry_461.html].
但是我不确定如何将它与Spring数据休息联系起来(基本上是我将过滤器提供者注入spring数据休息对象映射器的部分).让我知道是否有人尝试过这个或者来自Spring数据团队的人有见解.
将自己发布答案如果我能够实现相同的目标.
UPDATE
所以我发现实现自定义过滤的方法是通过jackson BeanSerializerModifier.来自Twitter上的@cowtowncoder的大力帮助.也可以使用jackson过滤有用的参考或圣杯http://www.cowtowncoder.com/blog/archives/ 2011/02/entry_443.html
我正在尝试在GCE上启动Kubernetes(k8s)群集.我跑的时候
gcloud components update kubectl
Run Code Online (Sandbox Code Playgroud)
在我得到的Windows机器上
错误:(gcloud.components.update)以下组件未知[kubectl]
我正在使用Spring Data JPA规范对实体进行通用查询。到目前为止,它运行良好。现在,当我尝试在通过EmbeddedId注释使用的复合键上使用这些键时,发生了问题。所以在这里我需要使用一个嵌套的属性来查询它说对象是否为Foo,并且我试图在id上写一个条件。例如id1。
@Entity
@Data
public class Foo implements Serializable {
private static final long serialVersionUID = 1L;
/** The key. */
@EmbeddedId
private FooKey id;
}
@Embeddable
@Data
public class FooKey implements Serializable {
private static final long serialVersionUID = 1L;
/** The key. */
private String id1;
private String id2;
}
Run Code Online (Sandbox Code Playgroud)
在规范中,我试图做
@Override
public Predicate toPredicate(Root<T> root, CriteriaQuery<?> query, CriteriaBuilder builder) {
// get root type
root.get(property).getJavaType()
Run Code Online (Sandbox Code Playgroud)
但这不适用于这种情况下的嵌套属性。有什么方法可以为复合键中的属性建立谓词。
spring ×5
java ×4
rest ×2
spring-boot ×2
spring-mvc ×2
android ×1
hamcrest ×1
jackson ×1
jpa ×1
json ×1
kubernetes ×1
unit-testing ×1