Springboot --- 注入第三方jar包,直接可以使用@Autowired
项目中如何注入第三方jar包在使用时,可以直接通过@Autowised导入
·
Springboot --- 注入第三方jar包,可以使用@Autowired
整理不易,不喜勿喷。谢谢
SpringBoot — 整合Ldap.
SpringBoot — 整合Spring Data JPA.
SpringBoot — 整合Elasticsearch.
SpringBoot — 整合spring-data-jpa和spring-data-elasticsearch.
SpringBoot — 整合thymeleaf.
SpringBoot — 注入第三方jar包.
SpringBoot — 整合Redis.
Springboot — 整合slf4j打印日志.
Springboot — 整合定时任务,自动执行方法.
Springboot — 配置多数据源,使用JdbcTemplate以及NamedParameterJdbcTemplate.
Sprignboot — 详解pom.xml中build和profile.
SpringBoot — 监控.
SpringBoot — 缓存Cache/Redis.
SpringBoot与Zookeeper.
Git的使用.
因为类没有被@Service,@Repository等类注解,如果我们想用@Autowired注入会报错
// An highlighted block
@Autowired
private Cloner cloner;
import com.rits.cloning.Cloner;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
@Configuration
public class CommonConfiguration {
@Bean
public Cloner cloner() {
return new Cloner();
}
@Bean(name = "freeMarkerConfigure")
public freemarker.template.Configuration freeMarkerConfigure() throws IOException {
freemarker.template.Configuration configuration = new freemarker.template.Configuration(freemarker.template.Configuration.VERSION_2_3_28);
configuration.setDefaultEncoding(StandardCharsets.UTF_8.name());
configuration.setClassForTemplateLoading(this.getClass(), "/ftls");
return configuration;
}
}
更多推荐
已为社区贡献5条内容
所有评论(0)