我知道这可能看起来像是一个先前提出的问题,但我在这里遇到了一个不同的问题.
我有一个只有静态方法的实用程序类.我没有,我不会从中得到一个实例.
public class Utils{
private static Properties dataBaseAttr;
public static void methodA(){
}
public static void methodB(){
}
}
Run Code Online (Sandbox Code Playgroud)
现在我需要Spring用数据库属性填充dataBaseAttr属性.Spring配置是:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd">
<util:properties id="dataBaseAttr"
location="file:#{classPathVariable.path}/dataBaseAttr.properties" />
</beans>
Run Code Online (Sandbox Code Playgroud)
我已经在其他bean中完成了它,但是这个类(Utils)中的问题不是bean,如果我把它变成bean没什么变化我仍然不能使用变量,因为类不会被实例化并且变量总是等于null.
我们有一个 Angular 应用程序 (SSR),我需要在构建期间内联一些 SVG 图标。这主要是为了减少我们节点服务器的点击。
我们使用angular-svg-icon在运行时内联 SVG。我研究了ng-inline-svg它也在运行时运行。
我不想手动将它们添加到 HTML 中,以免污染代码。有没有办法在编译/构建期间执行此操作?
我有一些对象让我们说两个,A和B.这些对象来自同一个类.我需要使用JAXB封送这些对象,输出XML应采用以下形式:
<Root>
<A>
<ID> an id </ID>
</A>
<B>
<ID> an id </ID>
</B>
</Root>
<!-- Then all A and B attributes must be listed !-->
<A>
<ID> an id </ID>
<attribute1> value </attribute1>
<attribute2> value </attribute2>
</A>
<B>
<ID> an id </ID>
<attribute1> value </attribute1>
<attribute2> value </attribute2>
</B>
Run Code Online (Sandbox Code Playgroud)
如何在JAXB中生成此格式?任何帮助表示赞赏.
更新: 更具体地说,假设我们有这样的Human类:
@XmlRootElement
public class Human {
private String name;
private int age;
private Integer nationalID;
public String getName() {
return name;
}
public void setName(String name) {
this.name …Run Code Online (Sandbox Code Playgroud)