Questions tagged [spring-annotations]

A common placeholder for issues related to the use of annotations with the Spring framework

The Spring Framework () provides several annotation-driven configuration options from wiring beans to managing transaction.

Annotation types

JSR support

  • JSR 107
    • @CacheResult
    • @CachePut
    • @CacheRemove
    • @CacheRemoveAll
    • @CacheDefaults
    • @CacheKey
    • @CacheValue
  • JSR 250:
    • @Resource
  • JSR 303:
    • @Valid
    • @NotNull
    • @Size, etc
  • JSR 330:
    • @Inject
    • @Named

Useful links

1301 questions
0
votes
2 answers

Spring 3 MVC Request parameter mapping. Two parameters from the same class while calling a handler in the controller

I am trying to figure out how to pass two different parameters of the same class through the URL to a handler method in the controller. For example, given a "Foo" class with an "id" parameter(I am saying just one parameter to keep it simple, but…
raspayu
  • 5,089
  • 5
  • 37
  • 50
0
votes
4 answers

Spring annotations - good or bad?

I recently cam across a class like this: public class SomeDao { @Inject private DataSource dataSource; @Value("#{someMap['someDao.sql']}") private String sql; private JdbcTemplate jdbcTemplate; @PostConstruct private void…
lance-java
  • 25,497
  • 4
  • 59
  • 101
0
votes
2 answers

unable to use Spring Advice(@Before) using annotations

I am new to springs and trying to run a simple java application with java advices.... xml file...
-1
votes
1 answer

For GET web service , it is working fine in local and same code is not working in web logic server

For GET web service , while hitting the WebService in postman, able to retrieve data from local and same code is not working in web logic server. Input data format : JSON Output data format : JSON For another WebService , which we are not providing…
-1
votes
1 answer

Spring custom validation annotation isn't working because of null pointer exception?

I have this custom annotation interface: @Documented @Constraint(validatedBy = NameValidator.class) @Retention(RetentionPolicy.RUNTIME) @Target({ElementType.FIELD}) public @interface NameValidation { String message() default "Name invalid"; …
-1
votes
1 answer

Test failed with "HTTP Status: '404' -> incorrect JSON status mapping for 'unknown error' (500 expected)" since the bean holds previous session value

Test running in browserstack, the test initialized all beans with the newly generated driver session as soon as it started. In the event that the session expires, a new driver instance will be generated. However, despite the fact that a new session…
-1
votes
1 answer

User @Value springboot annotation as enum value

Given: application.yml --> content kafka: topicA: topic-a topicB: topic-b public enum KafkaTopicBeanMapping { TOPICA(@Value("${kafka.topicA}", "ratelimiterABean")); TOPICB(@Value("${kafka.topicB}", "ratelimiterBBean")); private…
Noob
  • 174
  • 1
  • 2
  • 19
-1
votes
1 answer

Creating multiple DataSource in Spring framework is expensive

In my spring mvc application , I have two different MySql database connections. One is for whole data storage and other one is for login history- which insert data daily in a specific period. I have created two separate Datasource (one via…
Arun
  • 107
  • 2
  • 2
  • 10
-1
votes
1 answer

Can two rest resources have same methods and request mapping but different @path(url) in Restful service

@Path("/users/A") public class UserResource1 { @GET @Produces("text/xml") public String getUser(@PathParam("username") String userName) { ... } } @Path("/users/B") public class UserResource2 { @GET …
-1
votes
1 answer

@Qualifier & @Autowired object coming as null

I am having following code below. @Builder(toBuilder = true) @AllArgsConstructor(access = AccessLevel.PRIVATE) @NoArgsConstructor(access = AccessLevel.PRIVATE) @ToString @EqualsAndHashCode @Configurable public class Employee…
AnKr
  • 433
  • 1
  • 6
  • 20
-1
votes
2 answers

Spring : @Autowired annotation - where to view the actual changes?

Based on the example being followed here : https://dzone.com/articles/autowiring-in-spring import org.springframework.stereotype.Component; @Component public class Department { private String deptName; public String getDeptName() { …
-1
votes
2 answers

Can we interchange @Controller and @Service in spring?

Can we interchange @Controller and @Service in spring? I tried and it was working. How are they implemented internally?
-1
votes
1 answer

When is DI not suitable to use

I am reading a blog about DI and there are some sentences that I don't understand. What does it mean that DI is a singleton object at runtime and only those objects within the scanning range of spring(with @Component) can use DI by…
climy
  • 23
  • 6
-1
votes
1 answer

Getting Null pointer exception while Injecct the dependent Object using autowired annotaion

Hi I am new in spring can someone help me on this. problem- I am using spring 3.0 and I need to use the auto wire annotation and I have 2 beans 1)Employee bean 2)Address bean public class Employee { private String name ; private Long id; private…
-1
votes
2 answers

Autowire a class that extends a collection in Spring

I've got a class that extends a collection, specifically a HashMap. I'd like to use it as an autowired field in another class, however when I try to use the @autowired or @resource annotations in the following way: @Autowired private…
Zerg
  • 739
  • 4
  • 11
  • 22
1 2 3
86
87