@ComponentScan
and probably have some reading to do in order to understand how that works with with e.g. a starter.spring-security-saml2-service-provider
?
2.2.0
, how do users of spring-security-oauth2-boot (https://github.com/spring-projects/spring-security-oauth2-boot) deal with the removal of @WebMvcTest(controllers = MyControllerImpl.class, secure = false)
(https://github.com/spring-projects/spring-boot/issues/14227)? There is no @WithMockUser
.
spring-security-test
perhaps you don’t have that test util in your project?
I'm using spring-security-oauth2-autoconfigure
to make use of the OAuth2RestTemplate
. I have the autoconfgured web security disabled:
@Configuration
@EnableWebSecurity
public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
@Override
protected void configure(AuthenticationManagerBuilder auth) {
// No configuration disables security
}
@Override
protected void configure(HttpSecurity http) {
// No configuration disables security
}
}
But I needed to use secure = false
for my MockMvc
controller tests.
Hi guys, I'm trying to fetch a list of Entity that have some relations with lazy loading. When I try to use the relations I get the session closed error. What am I doing wrong?
My Entity:
@Entity
@Table(name="obj1")
public class Obj1 {
// Properties
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name="id")
private int id;
// Relationships
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "idobj2")
private Obj2 obj2;
// Constructors
public SmsMt() {
}
// Getter/Setters
...
// toString
@Override
public String toString() {
String obj_format = "id: %d, obj2.id: %d";
return String.format(
obj_format,
getId(),
getObj2().getId());
}
}
the JPARepository:
public interface Obj1Repository extends JpaRepository<Obj1, Integer> {
}
The method where I access it:
@Component
public class Obj1Reader implements ItemReader<Obj1> {
private static final Logger log = LoggerFactory.getLogger(Obj1.class);
@Autowired
private Obj1Repository obj1Repository;
private int nextIndex;
private List<Obj1> obj1s;
@PostConstruct
private void initialize() {
obj1s = obj1Repository.findAll();
nextIndex = 0;
for(Obj1 obj : obj1s){
log.info("Found Obj: " + obj);
}
}
@Override
public SmsMt read() throws Exception, UnexpectedInputException, ParseException, NonTransientResourceException {
...
}
}
And it throws an error in "Found Obj:" + obj because the toString tries to access the lazyLoading object
How do I keep the session open after I fetch the list?
the open in view configuration doesn't seem to help
@konstantinblaesi and @wilkinsona I have similar issue regarding deserialization of a json string with a key/value timestamp "sometimestamp": "2019-10-17T17:45:50" (ISO 8601 date and time representation) to a pojo with attribute/field/property LocalDateTime sometimestamp;
But I did do another project to test/verify/confirm the issue but it not happened, so there is some bug on my project that mess jackson deserialization.
Please, see those simple projects: https://gitlab.com/javatimegroup
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'fhirProperties': @EnableConfigurationProperties or @ConfigurationPropertiesScan must be used to add @ConstructorBinding type com.potreromed.phg.emr.fhir.FhirProperties
the class in questionpackage com.potreromed.phg.emr.fhir;
import ca.uhn.fhir.context.FhirVersionEnum;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.ConstructorBinding;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.stereotype.Component;
@Component
@ConstructorBinding
@EnableConfigurationProperties
@ConfigurationProperties( "fhir" )
public class FhirProperties {
private final FhirVersionEnum version;
private final String endpoint;
private final SystemCodes system;
FhirProperties( FhirVersionEnum version, String endpoint, SystemCodes system ) {
this.version = version;
this.endpoint = endpoint;
this.system = system;
}
public FhirVersionEnum getVersion() {
return version;
}
public String getEndpoint() {
return endpoint;
}
public SystemCodes getSystem() {
return system;
}
public static class SystemCodes {
private final String bodyweight;
private final String identifier;
public SystemCodes( String bodyweight, String identifier ) {
this.bodyweight = bodyweight;
this.identifier = identifier;
}
public String getBodyweight() {
return bodyweight;
}
public String getIdentifier() {
return identifier;
}
}
}
Hey folks... before the RC1 release, I was using my properties without @ConstructorBinding
. I followed the new documentation, added the annotation to see and it works.
@Configuration
@EnableConfigurationProperties(
MyProperties1::class,
MyProperties2::class
)
class PropertiesConfiguration
@ConstructorBinding
@ConfigurationProperties("app.props1")
data class MyProperties1(
val field: String
)
@ConstructorBinding
@ConfigurationProperties("app.props2")
data class MyProperties2(
val field: String
)
I just want to confirm if this is the expected way to declare the properties on 2.2.x or may I doing something else and don't even need to use @ConstructorBinding
here?
@EnableConfigurationProperties
if that package is scanned by your app (unrelated but 2.2 scans config props)
TransactionSynchronizationManager.registerSynchronization
and the primary transaction manager is ChainedKafkaTransactionManager
, the synchronization will by default fail because KafkaTransactionManager
has synchronization disabled. Fair enough, i can enable it. But really what i would like to do is a way to register the Synchronization with the outermost DataSourceTransactionManager that is also active, it seems that synchronizations are registered with the innermost TM automatically.
KafkaTransactionManager
* Transaction synchronization is turned off by default, as this manager might be used alongside a datastore-based
* Spring transaction manager like DataSourceTransactionManager, which has stronger needs for synchronization. Only
* one manager is allowed to drive synchronization at any point of time.
FooClient
class implementing communication with a REST API , tested in FooClientTest
which is annotated with @RestClientTest({FooAPIClient.class, FooAPIConnection.class, FooAPIProperties.class, FooAPIAutoConfiguration.class})
FooAPIProperties.class
that are annotated with @Value(...)
. Any tips what I need to change to make spring inject these values from the properties file?
Hi, I'm trying to send and get cookies to my browser. Sending cookies works just fine, but when I tried to get those cookies back, the path
and age
are turning to null , -1
But I can see in the browser that these cookies actually have path and expire date!
So does anyone knows why this is happening?
Here is how I did it:
@GetMapping("/home")
public void homePage(HttpServletRequest request, HttpServletResponse response){
System.out.println("A request comes in");
HttpServletResponse httpServletResponse = response;
HttpServletRequest httpServletRequest = request;
Cookie cookie= new Cookie("C10","this-is-the-value-of-the-cookie");
cookie.setPath("/");
cookie.setMaxAge(86400);
httpServletResponse.addCookie(cookie);
if(httpServletRequest !=null){
Cookie[] cookies = httpServletRequest.getCookies();
for (Cookie cookie1: cookies){
System.out.println("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"+cookie1.getName()+ " and the path of this cookie is: "
+ cookie1.getPath()+ " Expire date: "+ cookie1.getMaxAge()+" Value of the cookie: "+cookie1.getValue());
}
}
Ant the output:
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^Key5002 and the path of this cookie is: null Expire date: -1 Value of the cookie: Value5002
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^Key6001 and the path of this cookie is: null Expire date: -1 Value of the cookie: Value6001
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^Key6002 and the path of this cookie is: null Expire date: -1 Value of the cookie: Value6002
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^Key7001 and the path of this cookie is: null Expire date: -1 Value of the cookie: Value7001
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^Key7002 and the path of this cookie is: null Expire date: -1 Value of the cookie: Value7002
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^Key70001 and the path of this cookie is: null Expire date: -1 Value of the cookie: Value70001
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^Key70002 and the path of this cookie is: null Expire date: -1 Value of the cookie: Value70002
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^Key5001 and the path of this cookie is: null Expire date: -1 Value of the cookie: Value5001
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^JSESSIONID and the path of this cookie is: null Expire date: -1 Value of the cookie: BFF2E7B669508E8C89B3D472F18C4665
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^cookie2 and the path of this cookie is: null Expire date: -1 Value of the cookie: this-is-the-value-of-the-cookie
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^C10 and the path of this cookie is: null Expire date: -1 Value of the cookie: this-is-the-value-of-the-cookie