Remove @Autowired from constructors where class has single constructor

Closes gh-5226
pull/5303/head
Andy Wilkinson 9 years ago
parent 3ca67e669d
commit 355860fd09

@ -1,5 +1,5 @@
/*
* Copyright 2014-2015 the original author or authors.
* Copyright 2014-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -21,8 +21,6 @@ import java.io.File;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
/**
* A {@link HealthIndicator} that checks available disk space and reports a status of
* {@link Status#DOWN} when it drops below a configurable threshold.
@ -41,7 +39,6 @@ public class DiskSpaceHealthIndicator extends AbstractHealthIndicator {
* Create a new {@code DiskSpaceHealthIndicator}.
* @param properties the disk space properties
*/
@Autowired
public DiskSpaceHealthIndicator(DiskSpaceHealthIndicatorProperties properties) {
this.properties = properties;
}

@ -116,7 +116,6 @@ public class AuthenticationManagerConfiguration {
private final SecurityProperties securityProperties;
@Autowired
SpringBootAuthenticationConfigurerAdapter(SecurityProperties securityProperties) {
this.securityProperties = securityProperties;
}

@ -1,5 +1,5 @@
/*
* Copyright 2012-2015 the original author or authors.
* Copyright 2012-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -78,7 +78,6 @@ public class OAuth2ResourceServerConfiguration {
private ResourceServerProperties resource;
@Autowired
public ResourceSecurityConfigurer(ResourceServerProperties resource) {
this.resource = resource;
}

@ -1,5 +1,5 @@
/*
* Copyright 2012-2015 the original author or authors.
* Copyright 2012-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -114,7 +114,6 @@ public class SecurityFilterAutoConfigurationEarlyInitializationTests {
private static final long serialVersionUID = 1L;
@Autowired
public JacksonModuleBean(DeserializerBean myDeser) {
addDeserializer(SourceType.class, myDeser);
}

@ -1,5 +1,5 @@
/*
* Copyright 2012-2015 the original author or authors.
* Copyright 2012-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -19,7 +19,6 @@ package sample.cache;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.cache.CacheManager;
import org.springframework.stereotype.Component;
@ -31,7 +30,6 @@ public class CacheManagerCheck implements CommandLineRunner {
private final CacheManager cacheManager;
@Autowired
public CacheManagerCheck(CacheManager cacheManager) {
this.cacheManager = cacheManager;
}

@ -1,5 +1,5 @@
/*
* Copyright 2012-2015 the original author or authors.
* Copyright 2012-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -20,7 +20,6 @@ import java.util.Arrays;
import java.util.List;
import java.util.Random;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Profile;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
@ -54,7 +53,6 @@ class SampleClient {
private final Random random;
@Autowired
public SampleClient(CountryRepository countryService) {
this.countryService = countryService;
this.random = new Random();

@ -1,5 +1,5 @@
/*
* Copyright 2012-2013 the original author or authors.
* Copyright 2012-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -19,7 +19,6 @@ package sample.data.jpa.service;
import sample.data.jpa.domain.City;
import sample.data.jpa.domain.HotelSummary;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Component;
@ -35,7 +34,6 @@ class CityServiceImpl implements CityService {
private final HotelRepository hotelRepository;
@Autowired
public CityServiceImpl(CityRepository cityRepository,
HotelRepository hotelRepository) {
this.cityRepository = cityRepository;

@ -1,5 +1,5 @@
/*
* Copyright 2012-2013 the original author or authors.
* Copyright 2012-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -27,7 +27,6 @@ import sample.data.jpa.domain.RatingCount;
import sample.data.jpa.domain.Review;
import sample.data.jpa.domain.ReviewDetails;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Component;
@ -42,7 +41,6 @@ class HotelServiceImpl implements HotelService {
private final ReviewRepository reviewRepository;
@Autowired
public HotelServiceImpl(HotelRepository hotelRepository,
ReviewRepository reviewRepository) {
this.hotelRepository = hotelRepository;
@ -71,7 +69,7 @@ class HotelServiceImpl implements HotelService {
@Override
public Review addReview(Hotel hotel, ReviewDetails details) {
Review review = new Review(hotel, 1, details);
return reviewRepository.save(review);
return this.reviewRepository.save(review);
}
@Override

@ -1,5 +1,5 @@
/*
* Copyright 2012-2015 the original author or authors.
* Copyright 2012-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -19,7 +19,6 @@ package sample.hateoas.web;
import sample.hateoas.domain.Customer;
import sample.hateoas.domain.CustomerRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.hateoas.EntityLinks;
import org.springframework.hateoas.ExposesResourceFor;
import org.springframework.hateoas.Resource;
@ -42,7 +41,6 @@ public class CustomerController {
private final EntityLinks entityLinks;
@Autowired
public CustomerController(CustomerRepository repository, EntityLinks entityLinks) {
this.repository = repository;
this.entityLinks = entityLinks;

@ -1,5 +1,5 @@
/*
* Copyright 2012-2014 the original author or authors.
* Copyright 2012-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -19,7 +19,6 @@ package sample.jersey;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@Component
@ -28,7 +27,6 @@ public class Endpoint {
private Service service;
@Autowired
public Endpoint(Service service) {
this.service = service;
}

@ -1,5 +1,5 @@
/*
* Copyright 2012-2015 the original author or authors.
* Copyright 2012-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -25,7 +25,6 @@ import org.jooq.Query;
import org.jooq.Record;
import org.jooq.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowMapper;
@ -41,7 +40,6 @@ public class JooqExamples implements CommandLineRunner {
private final JdbcTemplate jdbc;
@Autowired
public JooqExamples(DSLContext dsl, JdbcTemplate jdbc) {
this.dsl = dsl;
this.jdbc = jdbc;

@ -1,5 +1,5 @@
/*
* Copyright 2012-2014 the original author or authors.
* Copyright 2012-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -18,7 +18,6 @@ package sample.atomikos;
import javax.transaction.Transactional;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jms.core.JmsTemplate;
import org.springframework.stereotype.Service;
@ -30,7 +29,6 @@ public class AccountService {
private final AccountRepository accountRepository;
@Autowired
public AccountService(JmsTemplate jmsTemplate, AccountRepository accountRepository) {
this.jmsTemplate = jmsTemplate;
this.accountRepository = accountRepository;

@ -1,5 +1,5 @@
/*
* Copyright 2012-2014 the original author or authors.
* Copyright 2012-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -18,7 +18,6 @@ package sample.bitronix;
import javax.transaction.Transactional;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jms.core.JmsTemplate;
import org.springframework.stereotype.Service;
@ -30,7 +29,6 @@ public class AccountService {
private final AccountRepository accountRepository;
@Autowired
public AccountService(JmsTemplate jmsTemplate, AccountRepository accountRepository) {
this.jmsTemplate = jmsTemplate;
this.accountRepository = accountRepository;

@ -1,5 +1,5 @@
/*
* Copyright 2012-2014 the original author or authors.
* Copyright 2012-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -16,7 +16,6 @@
package sample.jndi;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jms.core.JmsTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -29,7 +28,6 @@ public class AccountService {
private final AccountRepository accountRepository;
@Autowired
public AccountService(JmsTemplate jmsTemplate, AccountRepository accountRepository) {
this.jmsTemplate = jmsTemplate;
this.accountRepository = accountRepository;

@ -1,5 +1,5 @@
/*
* Copyright 2012-2014 the original author or authors.
* Copyright 2012-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -16,7 +16,6 @@
package sample.jndi;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@ -27,7 +26,6 @@ public class WebController {
private final AccountRepository repository;
@Autowired
public WebController(AccountService service, AccountRepository repository) {
this.service = service;
this.repository = repository;

@ -1,5 +1,5 @@
/*
* Copyright 2012-2015 the original author or authors.
* Copyright 2012-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package sample.groovytemplates.mvc;
import java.util.HashMap;
@ -23,7 +24,6 @@ import javax.validation.Valid;
import sample.groovytemplates.Message;
import sample.groovytemplates.MessageRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.validation.BindingResult;
import org.springframework.validation.FieldError;
@ -38,9 +38,9 @@ import org.springframework.web.servlet.mvc.support.RedirectAttributes;
@Controller
@RequestMapping("/")
public class MessageController {
private final MessageRepository messageRepository;
@Autowired
public MessageController(MessageRepository messageRepository) {
this.messageRepository = messageRepository;
}

@ -1,14 +1,17 @@
/*
* Copyright 2012-2015 the original author or authors.
* Copyright 2012-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package sample.web.ui.mvc;
@ -18,7 +21,6 @@ import javax.validation.Valid;
import sample.web.ui.Message;
import sample.web.ui.MessageRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.ModelAttribute;
@ -35,9 +37,9 @@ import org.springframework.web.servlet.mvc.support.RedirectAttributes;
@Controller
@RequestMapping("/")
public class MessageController {
private final MessageRepository messageRepository;
@Autowired
public MessageController(MessageRepository messageRepository) {
this.messageRepository = messageRepository;
}

@ -1,5 +1,5 @@
/*
* Copyright 2012-2015 the original author or authors.
* Copyright 2012-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -22,7 +22,6 @@ import java.util.concurrent.atomic.AtomicReference;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.socket.TextMessage;
import org.springframework.web.socket.WebSocketSession;
import org.springframework.web.socket.handler.TextWebSocketHandler;
@ -37,7 +36,6 @@ public class SimpleClientWebSocketHandler extends TextWebSocketHandler {
private final AtomicReference<String> messagePayload;
@Autowired
public SimpleClientWebSocketHandler(GreetingService greetingService,
CountDownLatch latch, AtomicReference<String> message) {
this.greetingService = greetingService;

@ -1,5 +1,5 @@
/*
* Copyright 2012-2015 the original author or authors.
* Copyright 2012-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -19,7 +19,6 @@ package samples.websocket.jetty.echo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.socket.CloseStatus;
import org.springframework.web.socket.TextMessage;
import org.springframework.web.socket.WebSocketHandler;
@ -35,7 +34,6 @@ public class EchoWebSocketHandler extends TextWebSocketHandler {
private final EchoService echoService;
@Autowired
public EchoWebSocketHandler(EchoService echoService) {
this.echoService = echoService;
}

@ -1,5 +1,5 @@
/*
* Copyright 2012-2015 the original author or authors.
* Copyright 2012-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -22,7 +22,6 @@ import java.util.concurrent.atomic.AtomicReference;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.socket.TextMessage;
import org.springframework.web.socket.WebSocketSession;
import org.springframework.web.socket.handler.TextWebSocketHandler;
@ -37,7 +36,6 @@ public class SimpleClientWebSocketHandler extends TextWebSocketHandler {
private final AtomicReference<String> messagePayload;
@Autowired
public SimpleClientWebSocketHandler(GreetingService greetingService,
CountDownLatch latch, AtomicReference<String> message) {
this.greetingService = greetingService;

@ -1,5 +1,5 @@
/*
* Copyright 2012-2015 the original author or authors.
* Copyright 2012-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -19,7 +19,6 @@ package samples.websocket.tomcat.echo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.socket.CloseStatus;
import org.springframework.web.socket.TextMessage;
import org.springframework.web.socket.WebSocketHandler;
@ -35,7 +34,6 @@ public class EchoWebSocketHandler extends TextWebSocketHandler {
private final EchoService echoService;
@Autowired
public EchoWebSocketHandler(EchoService echoService) {
this.echoService = echoService;
}

@ -1,5 +1,5 @@
/*
* Copyright 2012-2015 the original author or authors.
* Copyright 2012-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -22,7 +22,6 @@ import java.util.concurrent.atomic.AtomicReference;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.socket.TextMessage;
import org.springframework.web.socket.WebSocketSession;
import org.springframework.web.socket.handler.TextWebSocketHandler;
@ -37,7 +36,6 @@ public class SimpleClientWebSocketHandler extends TextWebSocketHandler {
private final AtomicReference<String> messagePayload;
@Autowired
public SimpleClientWebSocketHandler(GreetingService greetingService,
CountDownLatch latch, AtomicReference<String> message) {
this.greetingService = greetingService;

@ -1,5 +1,5 @@
/*
* Copyright 2012-2015 the original author or authors.
* Copyright 2012-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -19,7 +19,6 @@ package samples.websocket.undertow.echo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.socket.CloseStatus;
import org.springframework.web.socket.TextMessage;
import org.springframework.web.socket.WebSocketHandler;
@ -35,7 +34,6 @@ public class EchoWebSocketHandler extends TextWebSocketHandler {
private final EchoService echoService;
@Autowired
public EchoWebSocketHandler(EchoService echoService) {
this.echoService = echoService;
}

@ -1,5 +1,5 @@
/*
* Copyright 2012-2014 the original author or authors.
* Copyright 2012-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -30,7 +30,6 @@ import org.jdom2.xpath.XPathExpression;
import org.jdom2.xpath.XPathFactory;
import sample.ws.service.HumanResourceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ws.server.endpoint.annotation.Endpoint;
import org.springframework.ws.server.endpoint.annotation.PayloadRoot;
import org.springframework.ws.server.endpoint.annotation.RequestPayload;
@ -46,7 +45,6 @@ public class HolidayEndpoint {
private HumanResourceService humanResourceService;
@Autowired
public HolidayEndpoint(HumanResourceService humanResourceService)
throws JDOMException, XPathFactoryConfigurationException,
XPathExpressionException {

@ -18,7 +18,6 @@ package org.springframework.boot.logging;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.stereotype.Component;
@ -50,7 +49,6 @@ public class LoggingApplicationListenerIntegrationTests {
private final LoggingSystem loggingSystem;
@Autowired
SampleService(LoggingSystem loggingSystem) {
this.loggingSystem = loggingSystem;
}

Loading…
Cancel
Save