spring-java-config

Using Spring Dynamic Languages Support from Java Configuration

南笙酒味 提交于 2019-12-01 16:20:59
I'd like to use Dynamic Languages Support of Spring Framework. In XML I'd just use the lang namespace, but I'd like to use Java configuration (i.e. @Configuration classes) only . I can imagine that I can do it by initializing all the hell from org.springframework.scripting.config package, inc. all the BeanPostProcessor s, Handler s, Parser s and FactoryBean s they create, but I really don't want to go there. Is there some other way? If there's none, what will be the minimal configuration needed to create a reloadable bean out of a Groovy script? Why don't you ask us directly by email? :-) I

Spring 4 mail configuration via java config

百般思念 提交于 2019-12-01 15:55:37
Is there some example of how MailSender can be configured via java config? All examples that I've seen uses xml to create needed beans: <bean id="mailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl"> <property name="host" value="mail.mycompany.com"/> </bean> <!-- this is a template message that we can pre-load with default state --> <bean id="templateMessage" class="org.springframework.mail.SimpleMailMessage"> <property name="from" value="customerservice@mycompany.com"/> <property name="subject" value="Your order"/> </bean> The code you posted (along with some small

Spring 4 mail configuration via java config

回眸只為那壹抹淺笑 提交于 2019-12-01 14:56:23
问题 Is there some example of how MailSender can be configured via java config? All examples that I've seen uses xml to create needed beans: <bean id="mailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl"> <property name="host" value="mail.mycompany.com"/> </bean> <!-- this is a template message that we can pre-load with default state --> <bean id="templateMessage" class="org.springframework.mail.SimpleMailMessage"> <property name="from" value="customerservice@mycompany.com"/>

Spring Batch Javaconfig - parameterize commit-interval aka chunksize

試著忘記壹切 提交于 2019-12-01 10:31:40
with Spring Batch xml based configuration you can parameterize the commit-interval / chunk size like: <job id="basicSimpleJob" xmlns="http://www.springframework.org/schema/batch"> <step id="basicSimpleStep" > <tasklet> <chunk reader="reader" processor="processor" writer="writer" commit-interval="#{jobParameters['commit.interval']}"> </chunk> </tasklet> </step> </job> with javaconfig based configuration it could look like @Bean public Step step( ItemStreamReader<Map<String, Object>> reader, ItemWriter<Map<String, Object>> writer, @Value("#{jobParameters['commit.interval']}") Integer

Autowire setter override with Java Config

懵懂的女人 提交于 2019-12-01 10:29:46
Consider the following class: public class MyBean { private A a; @Autowired(required=true) public void setA(A a) { this.a = a; } public A getA() { return a; } } There are cases when one need need to override the autowired injection, for example when Spring cannot find a single candidate for the injection. In XML I can have the following example: <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org

404 error using Spring MVC Java Config on JBoss

前提是你 提交于 2019-12-01 08:37:13
I wrote a small Spring MVC application with Java Config. It is working perfectly fine on Tomcat but not on JBoss EAP 6.2. It gets successfully deployed on JBoss but I get this warning when I request any page defined by Spring MVC and 404 error in browser. WARN [org.springframework.web.servlet.PageNotFound] (http-/127.0.0.1:8080-1) No mapping found for HTTP request with URI [/example-web/pages/login.jsp] in DispatcherServlet with name 'dispatcher' Here you can see my code: public class WebApplicationInitializer extends AbstractAnnotationConfigDispatcherServletInitializer { @Override protected

404 error using Spring MVC Java Config on JBoss

ぃ、小莉子 提交于 2019-12-01 07:25:20
问题 I wrote a small Spring MVC application with Java Config. It is working perfectly fine on Tomcat but not on JBoss EAP 6.2. It gets successfully deployed on JBoss but I get this warning when I request any page defined by Spring MVC and 404 error in browser. WARN [org.springframework.web.servlet.PageNotFound] (http-/127.0.0.1:8080-1) No mapping found for HTTP request with URI [/example-web/pages/login.jsp] in DispatcherServlet with name 'dispatcher' Here you can see my code: public class

Spring Batch Javaconfig - parameterize commit-interval aka chunksize

爱⌒轻易说出口 提交于 2019-12-01 07:10:42
问题 with Spring Batch xml based configuration you can parameterize the commit-interval / chunk size like: <job id="basicSimpleJob" xmlns="http://www.springframework.org/schema/batch"> <step id="basicSimpleStep" > <tasklet> <chunk reader="reader" processor="processor" writer="writer" commit-interval="#{jobParameters['commit.interval']}"> </chunk> </tasklet> </step> </job> with javaconfig based configuration it could look like @Bean public Step step( ItemStreamReader<Map<String, Object>> reader,

Spring Batch Table Prefix when using Java Config

◇◆丶佛笑我妖孽 提交于 2019-12-01 05:37:03
My Spring Batch repository (deployed on an Oracle database) lies in a different schema such that I need to prepend the schema name. When using XML configuration, this would be easy to do: <job-repository id="jobRepository" table-prefix="GFA.BATCH_" /> However, as I use Java Config, this turns out to be more tricky. The best solution I found is to have my Java Config class extend DefaultBatchConfigurer and override the createJobRepository() method: @Configuration @EnableBatchProcessing public class BatchConfiguration extends DefaultBatchConfigurer{ @Autowired private DataSource dataSource;

How do I define http \"security = 'none' in JavaConfig?

徘徊边缘 提交于 2019-12-01 04:04:54
I want to define something similar to this XML in Spring Boot using Java Config. <http pattern="/webservices/**" security="none"/> I need a different way of securing them and cannot do form-logins. Securing them will come later. For now, I want to stop securing them with http.formLogin(). I have overridden WebSecurityConfigurerAdapter.configure() as such. I cannot find an API to say, like this: http.securityNone().antMatchers("/webservices") Here is my configure() method now: @Override protected void configure(HttpSecurity http) throws Exception http.csrf().disable(); http.headers()