如何将xml bean转换为spring java bean

时间:2017-04-28 08:51:06

标签: java spring

我想将这个xml转换为新的Spring Java bean

Symbolic Name   com.MYPRJ.MYPRJ_LoginModule
Version 1.1.1.SNAPSHOT
Bundle Location jcrinstall:/apps/LoginModule/install/LoginModule_LoginModule-1.1.1-SNAPSHOT.jar
Last Modification   Fri Apr 28 13:55:20 IST 2017
Bundle Documentation    http://www.MYPRJ.com
Vendor  MYPRJ
Description Login Module fragment bundle
Start Level 20
Host Bundles    com.day.crx.sling.server (65)
Exported Packages   ---
Imported Packages   None
Manifest Headers    Bnd-LastModified: 1493367872832
Build-Jdk: 1.7.0_80
Built-By: Vivek Dhiman
Bundle-Description: Login Module fragment bundle
Bundle-DocURL: http://www.MYPRJ.com
Bundle-ManifestVersion: 2
Bundle-Name: com.MYPRJ.gwms - LoginModule_LoginModule
Bundle-SymbolicName: com.MYPRJ.MYPRJ_LoginModule
Bundle-Vendor: MYPRJ
Bundle-Version: 1.1.1.SNAPSHOT
Created-By: Apache Maven Bundle Plugin
Export-Package: com.MYPRJ.gwms.LoginModule.login; uses:="javax.jcr, com.MYPRJ.gwms.LoginModule.authenticator.ldap, org.slf4j, javax.security.auth.callback, javax.security.auth.login, javax.security.auth, org.apache.commons.lang, org.osgi.framework"; version="1.1.1.SNAPSHOT"
Fragment-Host: com.day.crx.sling.server
Ignore-Package: org.apache.jackrabbit.core.security.authentication, org.apache.jackrabbit.api.security.user, org.apache.jackrabbit.core.security.authentication.token, org.apache.jackrabbit.core.security, org.apache.jackrabbit.core.security.principal, org.apache.jackrabbit.api
Import-Package: com.MYPRJ.gwms.LoginModule.authenticator.ldap; version="[1.1, 2)", com.sun.security.auth; resolution:=optional, javax.jcr; version="[2.0, 3)", javax.security.auth, javax.security.auth.callback, javax.security.auth.login, org.apache.commons.lang; version="[2.5, 3)", org.osgi.framework; version="[1.5, 2)", org.slf4j; version="[1.5, 2)"
Manifest-Version: 1.0
Tool: Bnd-1.50.0

并且任何人都可以清楚地说明这种转换是如何进行的,以及它是如何工作的

Java类以

开头

@Bean

2 个答案:

答案 0 :(得分:0)

应该添加到你的@Configuration标记类中

@Bean
public VelocityEngineFactoryBean velocityEngine() {
    VelocityEngineFactoryBean b = new VelocityEngineFactoryBean ();
    b.setVelocityProperties(the map with all your key values);
    return b;
}

如果某些值是另一个bean,例如dataSourceLoader你可以@Autowire他们到同一个类并使用属性

答案 1 :(得分:0)

您的java类应使用@Configuration批注进行批注,并且该方法应使用@Bean进行批注。请参阅下面的

DataTable dt = new DataTable();         
dt.DefaultView.Sort = "Column_name desc";
dt = dt.DefaultView.ToTable();

有关基于Java的配置的更多信息,请参阅https://docs.spring.io/spring/docs/4.3.8.RELEASE/spring-framework-reference/htmlsingle/#beans-java-basic-concepts