本文整理了Java中org.springframework.beans.factory.annotation.Autowired
类的一些代码示例,展示了Autowired
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Autowired
类的具体详情如下:
包路径:org.springframework.beans.factory.annotation.Autowired
类名称:Autowired
暂无
代码示例来源:origin: hs-web/hsweb-framework
@Configuration
@EnableConfigurationProperties(MybatisProperties.class)
public class MyBatisAutoConfiguration {
@Autowired(required = false)
private Interceptor[] interceptors;
@Autowired
private ResourceLoader resourceLoader = new DefaultResourceLoader();
@Autowired(required = false)
private DatabaseIdProvider databaseIdProvider;
@Autowired(required = false)
private EntityFactory entityFactory;
代码示例来源:origin: spring-projects/spring-framework
/**
* Determine whether the given dependency declares an autowired annotation,
* checking its required flag.
* @see Autowired#required()
*/
@Override
public boolean isRequired(DependencyDescriptor descriptor) {
if (!super.isRequired(descriptor)) {
return false;
}
Autowired autowired = descriptor.getAnnotation(Autowired.class);
return (autowired == null || autowired.required());
}
代码示例来源:origin: sqshq/piggymetrics
@RestController
@RequestMapping("/recipients")
public class RecipientController {
@Autowired
private RecipientService recipientService;
@RequestMapping(path = "/current", method = RequestMethod.GET)
public Object getCurrentNotificationsSettings(Principal principal) {
return recipientService.findByAccountName(principal.getName());
}
@RequestMapping(path = "/current", method = RequestMethod.PUT)
public Object saveCurrentNotificationsSettings(Principal principal, @Valid @RequestBody Recipient recipient) {
return recipientService.save(principal.getName(), recipient);
}
}
代码示例来源:origin: spring-projects/spring-framework
@Configuration
@Import(NameConfig.class)
static class AutowiredConfig {
@Autowired String autowiredName;
@Bean TestBean testBean() {
TestBean testBean = new TestBean();
testBean.name = autowiredName;
return testBean;
}
}
代码示例来源:origin: spring-projects/spring-framework
@Component @Lazy
static class StandardPojo {
@Autowired @Qualifier("interesting") TestBean testBean;
@Autowired @Boring TestBean testBean2;
}
代码示例来源:origin: shuzheng/zheng
/**
* CmsCommentService实现
* Created by shuzheng on 2017/4/5.
*/
@Service
@Transactional
@BaseService
public class CmsCommentServiceImpl extends BaseServiceImpl<CmsCommentMapper, CmsComment, CmsCommentExample> implements CmsCommentService {
private static final Logger LOGGER = LoggerFactory.getLogger(CmsCommentServiceImpl.class);
@Autowired
CmsCommentMapper cmsCommentMapper;
}
代码示例来源:origin: spring-cloud-incubator/spring-cloud-alibaba
@Autowired(required = false)
private AliCloudEdasSdk aliCloudEdasSdk;
@Autowired(required = false)
private EdasProperties edasProperties;
@Autowired(required = false)
private ScxProperties scxProperties;
@Autowired(required = false)
private OssProperties ossProperties;
@Autowired(required = false)
private AnsProperties ansProperties;
@Autowired(required = false)
private AcmProperties acmProperties;
@Autowired(required = false)
private ScxContextAutoConfiguration scxContextAutoConfiguration;
@Autowired(required = false)
private OssContextAutoConfiguration ossContextAutoConfiguration;
@Autowired(required = false)
private AnsContextAutoConfiguration ansContextAutoConfiguration;
@Autowired(required = false)
private AcmContextBootstrapConfiguration acmContextBootstrapConfiguration;
代码示例来源:origin: macrozheng/mall
/**
* 商品优选管理Controller
* Created by macro on 2018/6/1.
*/
@Controller
@Api(tags = "CmsPrefrenceAreaController", description = "商品优选管理")
@RequestMapping("/prefrenceArea")
public class CmsPrefrenceAreaController {
@Autowired
private CmsPrefrenceAreaService prefrenceAreaService;
@ApiOperation("获取所有商品优选")
@RequestMapping(value = "/listAll", method = RequestMethod.GET)
@ResponseBody
public Object listAll() {
List<CmsPrefrenceArea> prefrenceAreaList = prefrenceAreaService.listAll();
return new CommonResult().success(prefrenceAreaList);
}
}
代码示例来源:origin: ityouknow/spring-boot-examples
@Component
public class HelloSender {
@Autowired
private AmqpTemplate rabbitTemplate;
public void send() {
String context = "hello " + new Date();
System.out.println("Sender : " + context);
this.rabbitTemplate.convertAndSend("hello", context);
}
}
代码示例来源:origin: spring-projects/spring-framework
@Configuration
public static class AStrich {
@Autowired
B b;
@Bean
public Z z() {
return new Z();
}
}
代码示例来源:origin: alibaba/dubbo-spring-boot-starter
@Configuration
@ConditionalOnClass(Service.class)
@ConditionalOnBean(annotation = EnableDubboConfiguration.class)
@AutoConfigureAfter(DubboAutoConfiguration.class)
@EnableConfigurationProperties(DubboProperties.class)
public class DubboProviderAutoConfiguration extends DubboCommonAutoConfiguration {
@Autowired
private ApplicationContext applicationContext;
@Autowired
private DubboProperties properties;
代码示例来源:origin: spring-cloud/spring-cloud-kubernetes
@Configuration
@Import(KubernetesAutoConfiguration.class)
@EnableConfigurationProperties({ ConfigMapConfigProperties.class,
SecretsConfigProperties.class })
protected static class KubernetesPropertySourceConfiguration {
@Autowired
private KubernetesClient client;
@Bean
@ConditionalOnProperty(name = "spring.cloud.kubernetes.config.enabled", matchIfMissing = true)
public ConfigMapPropertySourceLocator configMapPropertySourceLocator(
ConfigMapConfigProperties properties) {
return new ConfigMapPropertySourceLocator(client, properties);
}
@Bean
@ConditionalOnProperty(name = "spring.cloud.kubernetes.secrets.enabled", matchIfMissing = true)
public SecretsPropertySourceLocator secretsPropertySourceLocator(
SecretsConfigProperties properties) {
return new SecretsPropertySourceLocator(client, properties);
}
}
}
代码示例来源:origin: apache/kylin
@Controller
@RequestMapping(value = "/user_group")
public class KylinUserGroupController extends BasicController {
@Autowired
@Qualifier("userGroupService")
private IUserGroupService userGroupService;
@RequestMapping(value = "/groups", method = {RequestMethod.GET}, produces = {"application/json"})
@ResponseBody
public List<String> listUserAuthorities(@RequestParam(value = "project") String project) throws IOException {
return userGroupService.listAllAuthorities(project);
}
}
代码示例来源:origin: jersey/jersey
@Override
public Object resolve(Injectee injectee) {
AnnotatedElement parent = injectee.getParent();
String beanName = null;
if (parent != null) {
Qualifier an = parent.getAnnotation(Qualifier.class);
if (an != null) {
beanName = an.value();
}
}
boolean required = parent != null ? parent.getAnnotation(Autowired.class).required() : false;
return getBeanFromSpringContext(beanName, injectee, required);
}
代码示例来源:origin: sqshq/piggymetrics
@RestController
@RequestMapping("/users")
public class UserController {
@Autowired
private UserService userService;
@RequestMapping(value = "/current", method = RequestMethod.GET)
public Principal getUser(Principal principal) {
return principal;
}
@PreAuthorize("#oauth2.hasScope('server')")
@RequestMapping(method = RequestMethod.POST)
public void createUser(@Valid @RequestBody User user) {
userService.create(user);
}
}
代码示例来源:origin: spring-projects/spring-framework
@Configuration
@Import({ConditionalConfiguration.class, UnconditionalConfiguration.class})
protected static class ConditionalThenUnconditional {
@Autowired
private BeanOne beanOne;
}
代码示例来源:origin: gocd/gocd
@Component
public class AgentRemoteHandler {
private static final Logger LOGGER = LoggerFactory.getLogger(AgentRemoteHandler.class);
private Map<String, Agent> agentSessions = new ConcurrentHashMap<>();
@Qualifier("buildRepositoryMessageProducer")
@Autowired
private BuildRepositoryRemote buildRepositoryRemote;
@Autowired
private AgentService agentService;
@Autowired
private JobInstanceService jobInstanceService;
private ConsoleService consoleService;
代码示例来源:origin: shuzheng/zheng
/**
* CmsCategoryTagService实现
* Created by shuzheng on 2017/4/5.
*/
@Service
@Transactional
@BaseService
public class CmsCategoryTagServiceImpl extends BaseServiceImpl<CmsCategoryTagMapper, CmsCategoryTag, CmsCategoryTagExample> implements CmsCategoryTagService {
private static final Logger LOGGER = LoggerFactory.getLogger(CmsCategoryTagServiceImpl.class);
@Autowired
CmsCategoryTagMapper cmsCategoryTagMapper;
}
代码示例来源:origin: hs-web/hsweb-framework
@Configuration
@AutoConfigureAfter(FlowableAutoConfiguration.CustomEntityManagerAutoConfiguration.class)
@MapperScan(value = "org.hswebframework.web.workflow.dao", markerInterface = Dao.class
, sqlSessionFactoryRef = "sqlSessionFactory")
public class FlowableAutoConfiguration {
@Autowired(required = false)
private List<SessionFactory> sessionFactories;
@Autowired(required = false)
private List<ActivitiEventListener> activitiEventListeners;
代码示例来源:origin: macrozheng/mall
/**
* 会员等级管理Controller
* Created by macro on 2018/4/26.
*/
@Controller
@Api(tags = "UmsMemberLevelController",description = "会员等级管理")
@RequestMapping("/memberLevel")
public class UmsMemberLevelController {
@Autowired
private UmsMemberLevelService memberLevelService;
@RequestMapping(value = "/list",method = RequestMethod.GET)
@ApiOperation("查询所有会员等级")
@ResponseBody
public Object list(@RequestParam("defaultStatus") Integer defaultStatus){
List<UmsMemberLevel> memberLevelList = memberLevelService.list(defaultStatus);
return new CommonResult().success(memberLevelList);
}
}
内容来源于网络,如有侵权,请联系作者删除!