Where do I put my XML beans in a Spring Boot application?

后端 未结 3 803
小鲜肉
小鲜肉 2020-12-23 22:47

I\'m getting back into Spring (currently v4). It\'s all wonderful now with @SpringBootApplication and the other annotations but all the documentation seems to f

3条回答
  •  情话喂你
    2020-12-23 23:39

    You also can translate the XML config to a Java config. In your case it would look like:

    @Bean
    public DefaultSftpSessionFactory sftpSessionFactory() {
        DefaultSftpSessionFactory factory = new DefaultSftpSessionFactory();
        factory.setHost("localhost");
        factory.setPrivateKey(new ClassPathResource("classpath:META-INF/keys/sftpTest"));
        factory.setPrivateKeyPassphrase("springIntegration");
        factory.setPort(22);
        factory.setUser("kermit");
        return factory;
    }
    

    You can put this method in the class with the @SpringBootApplication annotation.

提交回复
热议问题