Create a simple PostgreSQL Database Table psql mydb mydb=# create user john with password ‘secret’; CREATE ROLE mydb=# create table person( personid serial, name varchar(30), age integer, height decimal (4,2) ); NOTICE: CREATE TABLE will create implicit sequence “person_personid_seq” for serial …
These instructions are for Eclipse or Spring Tool Suite (STS) 1. Make Certain you have a Database Connection Window -> Show View -> Other -> Database Management -> Database Explorer Database Connections -> New -> PostgreSQL -> Next New Driver …
Obviously location services and find my iPhone are useless if the first thing a would-be thief does is turn off location services and find my iPhone. Here is a great article that explains how to lock down location services and …
I couldn’t find any updates to the Pom.xml in Chapter6 of the examples for the book JBoss Drools Business Rules, so I’ve updated it myself. This current version works as of 3.1.2013 [sourcecode language=”xml”] <?xml version=”1.0″ encoding=”UTF-8″?> <project xsi:schemaLocation=”http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd” …
The following app-context.xml [sourcecode language=”xml”] <?xml version=”1.0″ encoding=”UTF-8″?> <beans xmlns=”http://www.springframework.org/schema/beans” xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance” xmlns:context=”http://www.springframework.org/schema/context” xmlns:p=”http://www.springframework.org/schema/p” xsi:schemaLocation=”http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd”> <context:annotation-config/> <bean id=”profile” class=”com.skills421.spring15.beans.Profile”/> <bean id=”student1″ class=”com.skills421.spring15.beans.Student” p:name=”John Doe” p:age=”21″/> <bean id=”student2″ class=”com.skills421.spring15.beans.Student” p:name=”Jane Doe” p:age=”19″/> </beans> [/sourcecode] can be replaced with the …
What Doesn’t Change app-context.xml [sourcecode language=”xml”] <?xml version=”1.0″ encoding=”UTF-8″?> <beans xmlns=”http://www.springframework.org/schema/beans” xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance” xmlns:context=”http://www.springframework.org/schema/context” xmlns:p=”http://www.springframework.org/schema/p” xsi:schemaLocation=”http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd”> <context:annotation-config/> <bean id=”profile” class=”com.skills421.spring15.beans.Profile”/> <bean id=”student1″ class=”com.skills421.spring15.beans.Student” p:name=”John Doe” p:age=”21″/> <bean id=”student2″ class=”com.skills421.spring15.beans.Student” p:name=”Jane Doe” p:age=”19″/> </beans> [/sourcecode] Student.java [sourcecode language=”java”] package …
[sourcecode language=”xml”] <?xml version=”1.0″ encoding=”UTF-8″?> <beans xmlns=”http://www.springframework.org/schema/beans” xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance” xmlns:context=”http://www.springframework.org/schema/context” xsi:schemaLocation=”http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd”> <context:annotation-config/> </beans> [/sourcecode] Annotations include: @Required @Autowired @Qualifier @Resource @PostConstruct @PreDestroy Autowired Annotations @AutoWired @AutoWired(required=false) @AutoWired @Qualifier(“student1”) @Resource(name=”student1″) AutoWired = required by default
Initialization Callbacks Destruction Callbacks Initialization Callbacks public class Example1 implements InitializingBean { public void afterPropertiesSet() { } } <bean id=”exampleBean” class=”Example2″ init-method=”init”/> public class Example2 { public void init() { } } Destruction Callbacks public class Example1 implements DisposableBean { …
singleton (default) only one instance per Spring Container prototype any number of instances request scoped to an HTTP request (web-aware Spring ApplicationContext) session scoped to an HTTP session (web-aware Spring ApplicationContext) global-session scoped to a global HTTP session (web-aware Spring …
XML based config file Annotation-based configuration Java-based configuration XML based config file [sourcecode language=”xml”] <!–?xml version=”1.0″ encoding=”UTF-8″?–> <!– A simple bean definition –> <!– collaborators and configuration for this bean go here –> <!– A bean definition with lazy init …