bean work

This commit is contained in:
eugenp 2013-05-24 23:14:34 +03:00
parent 8b070d278b
commit 7245aa572a
9 changed files with 56 additions and 9 deletions

View File

@ -37,7 +37,7 @@
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>4.2.1.Final</version>
<version>4.2.2.Final</version>
</dependency>
<dependency>
<groupId>org.javassist</groupId>

View File

@ -23,7 +23,7 @@ public class MainWebAppInitializer implements WebApplicationInitializer {
// Create the 'root' Spring application context
final AnnotationConfigWebApplicationContext root = new AnnotationConfigWebApplicationContext();
root.scan("org.baeldung.spring.web.config");
root.scan("org.baeldung.spring.config");
// root.getEnvironment().setDefaultProfiles("embedded");
// Manages the lifecycle of the root application context

View File

@ -1,16 +1,24 @@
package org.baeldung.web;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@Component
public class BeanA {
public class BeanA implements InitializingBean {
@Autowired
private IBeanB b;
private IBeanC dependency;
public BeanA() {
super();
}
//
@Override
public void afterPropertiesSet() throws Exception {
System.out.println();
}
}

View File

@ -0,0 +1,12 @@
package org.baeldung.web;
import org.springframework.stereotype.Component;
@Component
public class BeanB1 implements IBeanB {
public BeanB1() {
super();
}
}

View File

@ -0,0 +1,12 @@
package org.baeldung.web;
import org.springframework.stereotype.Component;
@Component
public class BeanB2 implements IBeanB {
public BeanB2() {
super();
}
}

View File

@ -5,9 +5,9 @@ import org.springframework.transaction.annotation.Transactional;
@Component
@Transactional
public class BeanB implements IBeanB {
public class BeanC implements IBeanC {
public BeanB() {
public BeanC() {
super();
}

View File

@ -0,0 +1,5 @@
package org.baeldung.web;
public interface IBeanC {
//
}

View File

@ -0,0 +1,10 @@
# jdbc.X
jdbc.driverClassName=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://localhost:3306/spring_hibernate4_01?createDatabaseIfNotExist=true
jdbc.user=tutorialuser
jdbc.pass=tutorialmy5ql
# hibernate.X
hibernate.dialect=org.hibernate.dialect.MySQL5Dialect
hibernate.show_sql=false
hibernate.hbm2ddl.auto=create-drop

View File

@ -32,7 +32,7 @@
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>4.2.1.Final</version>
<version>4.2.2.Final</version>
</dependency>
<dependency>
<groupId>org.javassist</groupId>
@ -157,7 +157,7 @@
<properties>
<!-- Spring -->
<org.springframework.version>3.2.2.RELEASE</org.springframework.version>
<org.springframework.version>3.2.3.RELEASE</org.springframework.version>
<!-- logging -->
<org.slf4j.version>1.7.5</org.slf4j.version>
@ -169,7 +169,7 @@
<mockito.version>1.9.5</mockito.version>
<httpcore.version>4.2.4</httpcore.version>
<httpclient.version>4.2.4</httpclient.version>
<httpclient.version>4.2.5</httpclient.version>
<rest-assured.version>1.8.0</rest-assured.version>
<groovy.version>1.8.9</groovy.version>