看起来我在Spring 4.1.1中使用Spring Boot 1.2.6.RELEASE做的事情根本不起作用.我只是想访问应用程序属性并在必要时使用测试覆盖它们(不使用hack手动注入PropertySource)
这不起作用..
@TestPropertySource(properties = {"elastic.index=test_index"})
Run Code Online (Sandbox Code Playgroud)
这也不是..
@TestPropertySource(locations = "/classpath:document.properties")
Run Code Online (Sandbox Code Playgroud)
也不是..
@PropertySource("classpath:/document.properties")
Run Code Online (Sandbox Code Playgroud)
完整测试案例..
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(loader = AnnotationConfigContextLoader.class)
@TestPropertySource(properties = {"elastic.index=test_index"})
public class PropertyTests {
@Value("${elastic.index}")
String index;
@Configuration
@TestPropertySource(properties = {"elastic.index=test_index"})
static class ContextConfiguration {
}
@Test
public void wtf() {
assertEquals("test_index", index);
}
}
Run Code Online (Sandbox Code Playgroud)
导致
org.junit.ComparisonFailure:
Expected :test_index
Actual :${elastic.index}
Run Code Online (Sandbox Code Playgroud)
似乎3.x和4.x之间存在很多相互矛盾的信息,我找不到任何可行的信息.
任何见解将不胜感激.干杯!
在非常棘手的合并之后,我们现在必须在合并时输入提交消息,我注意到IDEA的git/log屏幕中的向下/向上箭头.
我认为它是"断开连接"但我如何重新连接远程分支?

这是一个有趣的问题,我不知道是我做错了什么还是 Maven 的限制。
该场景的最简单版本是有一个父 POM、单个子 POM 和一个聚合 POM。聚合 POM 只是将模块链接在一起。
当我安装聚合 POM 时,它没有找出子 POM 对父 POM 的依赖关系。我不希望有相对路径,根据我对 Maven 工件的理解应该是可能的。
任何见解将不胜感激。谢谢。
这是超级父级(别介意里面什么都没有)
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>my.group</groupId>
<artifactId>parent-uber</artifactId>
<version>0.0.2-SNAPSHOT</version>
<packaging>pom</packaging>
</project>
Run Code Online (Sandbox Code Playgroud)
这是孩子:
<?xml version="1.0" encoding="UTF-8"?>
<project>
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>my.group</groupId>
<artifactId>parent-uber</artifactId>
<version>0.0.2-SNAPSHOT</version>
</parent>
<groupId>my.group</groupId>
<artifactId>parent-java</artifactId>
<packaging>pom</packaging>
<properties>
</properties>
<build>
<!-- To define the plugin version in your parent POM -->
<pluginManagement>
<plugins>
<!-- All projects that extend this should have valid JavaDoc built-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions> …Run Code Online (Sandbox Code Playgroud) 我们正在尝试拥有 Swagger 2.0。基本上,它很棒,只是它忽略了 @JsonIdentityInfo 和 @JsonIdentityReference 注释。
public class Source {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@ManyToOne
@JsonIdentityReference(alwaysAsId=true)
@JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "name")
@JsonProperty("sourceDefinitionName")
private SourceDefinition sourceDefinition;
... getters and setters
}
Run Code Online (Sandbox Code Playgroud)
产生 Swagger 模式输出:
{
"id": 0,
"sourceDefinitionName": {
"configuration": {},
"driver": "string",
"id": "string",
"name": "string",
"sourceType": "QUERY",
"title": "string"
}
}
Run Code Online (Sandbox Code Playgroud)
您可以看到它确实读取了 @JsonProperty 注释,将“sourceDefinition”重命名为“sourceDefinitionName”,但该值应该只是一个字符串。
有谁对这种集成的此类问题有任何见解吗?
我制作了一个Maven插件,用于验证和实例化项目中的类.Maven插件何时在类路径中包含项目中的类?
插件不断抛出ClassNotFoundException.
在查看Maven文档并进行搜索后询问问题.
任何帮助将不胜感激.谢谢!
尝试将XPath与具有为根节点声明的默认命名空间的XML文件一起使用.
示例代码:
final SAXBuilder builder = new SAXBuilder();
final Document document = builder.build(originalFile);
final XPathFactory xFactory = XPathFactory.instance();
final String expression = String.format("//section[@label='%s']/section/section", LABEL);
final XPathExpression<Element> sectionExpression = xFactory.compile(expression, Filters.element());
final List<Element> sections = sectionExpression.evaluate(document);
Run Code Online (Sandbox Code Playgroud)
部分是空的.
XML的片段
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project xmlns="http://www.stellent.com/sitestudio/Project/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.stellent.com/sitestudio/Project/ http://www.stellent.com/sitestudio/ss_project_schema.xsd">
<section label="Index">
<section label="xyz">
<section label="child">
...
</section>
</section>
</section>
</project>
Run Code Online (Sandbox Code Playgroud)
删除xmlns="http://www.stellent.com/sitestudio/Project/"作品但不是解决方案!
为什么XPath不能知道这个默认命名空间?另外,它为什么关心?
更好的是,我怎么能一般地解决这个问题呢?
感谢您的任何见解.
由于在我开始这个项目之前就存在的原因,有些表的类型相似但 ID 列不同。
所以,当我尝试这个
@Entity
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
public abstract class Element implements Serializable {
public String title;
}
@Entity
public class PrimaryElement extends Element {
@Id
long pid;
}
@Entity
public class OtherElement extends Element {
@Id
long oid;
}
Run Code Online (Sandbox Code Playgroud)
但后来我得到一个明显的错误
No identifier specified for entity: Element
Run Code Online (Sandbox Code Playgroud)
现在,我不能很好地将 ID 放在 Element 类中,因为它们显然映射到不同的列。
我尝试过各种风格的 @Id 和 'abstract' 和 @MappedSuperClass 等等..
我完全不知所措。有没有解决的办法?
任何见解将不胜感激。
谢谢!
java ×6
maven ×2
git ×1
hibernate ×1
jackson ×1
jdom-2 ×1
jpa ×1
junit ×1
maven-plugin ×1
parent-pom ×1
pom.xml ×1
spring ×1
spring-boot ×1
swagger ×1
swagger-2.0 ×1
swagger-ui ×1
xml ×1
xpath ×1