虽然我已经成功地设置了spring客户机/服务器,并将GIT作为后端属性repo。但是,对于我的客户端代码之一的模块结构(maven),我有一个基本问题:
客户1:
common (maven module)
app (maven module)
web (Contains the spring boot application, bootstrap.properties, application.properties)
对于上面的结构,我能够从spring服务器中读取/刷新"web“模块的属性(因为这是我的SpringBootApplication ),但是无法理解如何在
我是Spring的新手。我正面临着Spring-Boot的问题。我正在尝试将一个字段从外部配置文件自动绑定到一个自动连接的bean中。我有以下课程
App.java
public class App {
@Autowired
private Service service;
public static void main(String[] args) {
final SpringApplication app = new SpringApplication(App.class);
//app.setShowBanner(false);
app.run();
}
我使用的是spring-boot-starter-web最新版本2.2.6.RELEASE,但我的应用程序总是为带有@value注释的变量返回null。
我的build.gradle
plugins {
id 'com.google.cloud.tools.jib' version '2.1.0'
id 'org.springframework.boot' version '2.2.6.RELEASE'
id 'io.spring.dependency-management' version '
目前,我在一个项目中工作,在这个项目中我创建了@Entity类@Repository来存储一些信息。我创建了一个服务,就像其他现有的服务一样,然后尝试将该@Service注释类注入到带有@RestController注释的控制器中。它工作得很好,能够正常运行应用程序,没有问题,也就是没有注入问题。 现在,当我尝试运行现有项目的测试时,它失败了,因为我的服务无法注入到控制器类中。获取此错误: No qualifying bean of type 'com.example.service.exampleService' available: expected at least 1
我无法通过模拟UserService.save()方法来返回虚拟用户对象来测试我的控制器类。
继续获得以下异常
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'webSecurityConfig': Unsatisfied dependency expressed through field 'userDetailsService'; nested exception is org.springf
我有一个不再绑定到YML属性源的@ConfigurationProperties类,该属性源在升级到Hoxton.SR7后通过Spring Cloud Config进行解析。在最新的Spring Boot2.2.9.RELEASE中使用Hoxton.SR4时,这段代码可以很好地工作。现在,我的属性没有绑定,当我尝试引用它们时,会收到NPE。以下是我的代码的快照: @Configuration
public class MyConfiguration {
@Bean
public MyPropertiesBean myPropertiesBean() {
return new
我当时正在做一个Spring Boot1.5的项目。它具有以下类型的配置类: @Configurtion
public class Foo{
@Autowired
private DependencyA dependencyA;
@Bean
public DependencyA getDependency(){
return new DependencyAImpl();
}
} 这在Spring Boot1.5中工作得很好,但当我升级到Spring Boot2时,这不再起作用,应用程序不会启动,并出现异常“no bean of type DependencyA fou
我正在使用intellij、Spring和Gradle。
我有一个发送电子邮件的班级。所述类是使用new运算符创建的。现在我了,@Configureable注解可以用来自动生成这样的类。不过,我似乎不能让它工作。也许有人对此有经验,可以给我指明正确的方向?
@Service
@EnableAsync
@Configurable(dependencyCheck=true,autowire= Autowire.BY_TYPE)
public class EmailCommand implements ICommand {
/**
* standa
我是Spring Boot和依赖注入的初学者,我无法理解Spring Boot中基于构造函数的依赖注入。我有一个名为ParameterDate的类,它看起来像这样:
public class ParameterDate {
private Date parameterDateUnadjusted;
private Date parameterDateAdjusted;
private Date parameterDateAdded;
private Date parameterDateChanged;
}
我还有另一个类,我想在这个类中使用ParameterD
我试图使用JWT令牌来保护REST。为了保存已编码的用户密码,我尝试使用bcrypt进行编码。然而,当我试图自动创建BCryptPasswordEncoder时,我会得到以下错误:
Could not autowire. No beans of BCryptPasswordEncoder type found. Check autowiring problems in bean class.
我的控制器就是这样的:
package com.starter.springsecurity.demo.controller;
import com.starter.springsecurity.dem
学习新春
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2018-10-20 19:55:30 [thread] ERROR o.s.boot.SpringApplication - Application run failed
org.springframework.context.ApplicationContextException: Unable to start web server; n
我正在尝试在spring boot应用中注入服务。然而,我得到了以下错误:
org.glassfish.hk2.api.UnsatisfiedDependencyException: There was no object available for injection at SystemInjecteeImpl(requiredType=RecommendationService,parent=RecommendationResourceImpl,qualifiers={},position=-1,optional=false,self=false,unqualified=null,1163