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

Does hasPermission return false if the authentication object is null

I have the below code change . - @PreAuthorize("isAuthenticated()") + @PreAuthorize("hasPermission(#dto.perusteId, 'peruste', 'LUKU')") public void setStarted(DokumenttiDto dto); As per the spring documentation, the authentication object…
Zack
  • 2,078
  • 10
  • 33
  • 58
0
votes
0 answers

Spring 4 with JPA (Hibernate implementation): Transaction not working (no transaction in progress)

Ok, this looks to be a repeated question, however, I have been searching for this over 2 days and no success. Below are the configuration details: Annotated App Config class @Configuration @ComponentScan(basePackages =…
kaps
  • 81
  • 2
  • 9
0
votes
1 answer

Use ?. operator in principal id checks for security

I have the below code change. - @PreAuthorize("isAuthenticated() and #employee.id == principal.id") + @PreAuthorize("#employee.id == principal?.id") Here the developer makes changes as shown above. Are the two security checks same? So if I…
Zack
  • 2,078
  • 10
  • 33
  • 58
0
votes
2 answers

BeanCreationException from Spring with annotation "@Context" and "@Loggable"

I have web application using Spring, Apache CXF and Jetty. Spring doesn't like the addition of an annotation called @Loggable to methods in one of my classes. First, the annotation @Loggable links to the class LogAspect, which logs request and…
Lars Andren
  • 8,601
  • 7
  • 41
  • 56
0
votes
1 answer

Can't find controller in Spring annotation for AJAX

I tried to load data via AJAX in Spring 3.0, but the AJAX URL can't find the controller in Spring, and I don't know how to fix this. I know while server start it looks up the URL and gets data but here I can't crate annotation properly in spring…
user3607180
  • 185
  • 2
  • 5
  • 14
0
votes
2 answers

Android as a Client, Server using Spring annotation,communication in JSON format,error while receiving in server

I want to develop android app which is connected to server which is developed using Spring,and they should communicate in JSON format. But When I send request to server with JSON object and try to receive it,it is showing…
Shreekant N
  • 858
  • 1
  • 13
  • 28
0
votes
2 answers

What is the purpose of the Spring Bean annotation name attribute?

I'm just learning spring, and something struck me as very odd about the annotation configurations using the name attribute as a string. @Bean(name = "com.my.injected.Service") public InjectedService injectedService() { return…
Patrick M
  • 10,547
  • 9
  • 68
  • 101
0
votes
1 answer

Spring Annotation trailing slash

I have a controller with @RequestMapping for root path "/". There are other controllers with say a @RequestMapping of "/test" etc. My application seems to be mapping correctly for paths like /appname/test, but if I add a trailing slash to the path,…
Eqbal
  • 4,722
  • 12
  • 38
  • 47
0
votes
1 answer

Spring security Login database using Annotation :NoSuchBeanDefinitionException

I am trying spring security login through database. My SecurityConfig code: @Configuration @EnableWebSecurity public class SecurityConfig extends WebSecurityConfigurerAdapter { @Autowired DataSource dataSource; @Autowired public…
Chaitanya Joshi
  • 304
  • 1
  • 4
  • 22
0
votes
1 answer

Spring annotation based SAP connector

I'm trying to move from a xml based config to java annotations I need your help getting this to work: Obviously I can't set the RemoteJco interface to my SapConnector but what can I do to get this xml-config working? @Bean public RmiProxyFactoryBean…
James Carter
  • 849
  • 3
  • 13
  • 29
0
votes
1 answer

Cache is empty after setting up and using ehcache in Spring

My code is below, when I get to the end and try to print out something from the cache, the key list is empty. @Configuration @EnableCaching public class EhcacheConfiguration implements CachingConfigurer { CacheConfiguration cacheConfiguration =…
smuggledPancakes
  • 9,881
  • 20
  • 74
  • 113
0
votes
1 answer

Unable to wire using ActiveProfile annotation

First time using Profiles and need help. I have an abstract base class (DecisionManagementRuleExecutor) that gets its dependency (RuleHandler) wired through annotation. @Component public class RuleHandler {...... public abstract class…
patb23
  • 387
  • 5
  • 21
0
votes
1 answer

Security annotation @PreAuthorize doesn't take effect in @Controller, only in @Service with Spring Security 3.2.5

As the title implies. Bellow is my spring security configuration: @Configuration @EnableGlobalMethodSecurity(proxyTargetClass = true, prePostEnabled = true) @EnableWebMvcSecurity public class SecurityConfig extends WebSecurityConfigurerAdapter { …
artaxerxe
  • 6,281
  • 21
  • 68
  • 106
0
votes
1 answer

Dependency Injection Autowiring Null with spring annotaion-driven components

I've created a spring-mvc application. the configurations look like below: dispatcher-servlet.xml
0
votes
2 answers

Accessing Annotation's Parameter ot Construction for Modification

I'm a little confused about exactly how annotations work so I could not locate the answer to this easily, even if it was right in front of my eyes without an explanation. Lets say for example we have this class //this happens to be a Spring…
JNYRanger
  • 6,829
  • 12
  • 53
  • 81