Skip to content

Tool for convert all Spring xml configurations to Spring java based configurations

License

Notifications You must be signed in to change notification settings

Akvel/spring-xml-to-java-converter

Repository files navigation

GitHub release (latest by date including pre-releases) Build Build Status Quality Gate Status GitHub

Spring-xml-to-java-converter

The tool for converting Spring XML configuration to Spring Java-Based configuration.

Just set parameters input path (-xp), output path(-op) and package name(-p) and the tool converts all supported types to Java class and remove them from XML.

Usage

You need java 11 to run this tool.

Simple run:

java -jar spring-xml-to-java-converter.jar -xp <XMLs base path> -op <Java classes base path> -p <Base java package name>

Full params list:

java -jar spring-xml-to-java-converter.jar -h

Example with class path (need for imports):

Unix

java -classpath "./spring-xml-to-java-converter.jar:/home/test/project/module1/target/classes/*:/home/test/project/module2/target/classes/*" pro.akvel.spring.converter.Convertor -xp "/home/test/project" -l DEBUG -p pro.akvel.config

Win

java -classpath "./spring-xml-to-java-converter.jar;C:\git\test\project\module1\target\classes;C:/git/home/test/project/module2/target/classes" pro.akvel.spring.converter.Convertor -xp "/home/test/project" -l DEBUG -p pro.akvel.config

Important! You must remove classpath: prefix from imports (<import resource="META-INF/test.xml"/>)

Limitations

Converter does not have access to your classes, so it has some limitation.

  • If your XML configuration misses any constructor params - the beans will be generated without them (You will see compilation error and you will need to fix it manually)
  • Skips bean elements named construct-Args. Because converter doesn't know real constructor params order
  • If constructor-arg does not has type attribute - value will be set to String type. (Supported only String, Integer and Long)
  • Property tags only support: ref and value
  • No implemented factories convert (XML factory, FactoryBean)
  • No implemented convertation beans that use factories and only Mergeable (except types List and Set)
  • New XML files do not include any comments (<!-- -->)
  • Tag <qualifier/> must have attribute type="org.springframework.beans.factory.annotation.Qualifier"
  • Not supported attrs xmlns:c="http://www.springframework.org/schema/c" and xmlns:p="http://www.springframework.org/schema/p"
  • Not supported EL expressions #{} and classpath:

Contributing

If I've made any errors anywhere in the implementation, please do let me know by raising an issue. If there's any cool addition you want to introduce, all PRs are appreciated!

License

Beer and pizza license

About

Tool for convert all Spring xml configurations to Spring java based configurations

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors 3

  •  
  •  
  •  

Languages