-
Notifications
You must be signed in to change notification settings - Fork 21
Quick Start guide for DD4T 2 Java
Setting up a Tridion > DD4T 2 stack can be done pretty quick. You need three things before you start:
- A Tridion environment setup and configured
- Maven
- The Tridion and other dependencies in your local repository.
If that's all there, follow the steps below to get started:
- Download the zip package from here and unpack it.
- Run the install-templates.bat and follow the steps.
It couldn't be easier!
Open the SDL Tridion Template Builder (if you don't have it installed, start Internet Explorer and browse to any Tridion CME, then click on the Tools ribbon and download the template builder from there).
Create a page template, give it any name you like, and add the 'Generate dynamic page' DD4T template building block to it. Save and close the template.
Create a component template, give it any name you like, and add the 'Generate dynamic component presentation' DD4T template building block to it. Save and close the template. Open the component template again, but this time from the CME. Link it to one ore more schemas.
You are now ready to publish pages.
To create a complete, but minimal Spring MVC web application to develop with, create a new project based on a Maven archetype:
- Create an empty directory where you want to develop the web application in
- Execute the following command after replacing the parameters in between the brackets ([com.example] and [mywebapp]):
For Web 8: mvn archetype:generate -DgroupId=[com.example] -DartifactId=[mywebapp] -DarchetypeGroupId=org.dd4t -DarchetypeArtifactId=dd4t-web8-archetype -DarchetypeVersion=1.1 -DarchetypeCatalog=remote
For Tridion 2011 / 2013:
mvn archetype:generate -DgroupId=[com.example] -DartifactId=[testapp] -DarchetypeGroupId=org.dd4t -DarchetypeArtifactId=dd4t-spring-mvc-archetype -DarchetypeVersion=1.6 -DarchetypeCatalog=remote
-
If you are on SDL Tridion 2013, use this command instead:
mvn archetype:generate -DgroupId=[com.example] -DartifactId=[mywebapp] -DarchetypeGroupId=org.dd4t -DarchetypeArtifactId=dd4t-spring-mvc-archetype -DarchetypeVersion=1.5 -DarchetypeCatalog=remote
-
Enter the requested information. Maven will ask you to specify a version (defaults to 1.0-SNAPSHOT) and will then ask you to confirm the settings.
-
The web application project is created if you see the following Maven output:
$ mvn archetype:generate -DgroupId=com.example -DartifactId=mywebapp -DarchetypeGroupId=org.dd4t -DarchetypeArtifactId=dd4t-spring-mvc-archetype -DarchetypeVersion=1.5 -DarchetypeCatalog=remote -DarchetypeCatalog=http://repo1.maven.org/maven2 [INFO] Scanning for projects... [INFO] Using the builder org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder with a thread count of 1 [INFO] ------------------------------------------------------------------------ [INFO] Building Maven Stub Project (No POM) 1 [INFO] ------------------------------------------------------------------------ [INFO] [INFO] >>> maven-archetype-plugin:2.3:generate (default-cli) @ standalone-pom >>> [INFO] [INFO] <<< maven-archetype-plugin:2.3:generate (default-cli) @ standalone-pom <<< [INFO] [INFO] --- maven-archetype-plugin:2.3:generate (default-cli) @ standalone-pom --- [INFO] Generating project in Interactive mode [INFO] Using property: groupId = com.example [INFO] Using property: artifactId = mywebapp Define value for property 'version': 1.0-SNAPSHOT: : [INFO] Using property: package = com.example Confirm properties configuration: groupId: com.example artifactId: mywebapp version: 1.0-SNAPSHOT package: com.example Y: : Y [INFO] ---------------------------------------------------------------------------- [INFO] Using following parameters for creating project from Archetype: dd4t-spring-mvc-archetype:1.4 [INFO] ---------------------------------------------------------------------------- [INFO] Parameter: groupId, Value: com.example [INFO] Parameter: artifactId, Value: mywebapp [INFO] Parameter: version, Value: 1.0-SNAPSHOT [INFO] Parameter: package, Value: com.example [INFO] Parameter: packageInPathFormat, Value: com/example [INFO] Parameter: version, Value: 1.0-SNAPSHOT [INFO] Parameter: package, Value: com.example [INFO] Parameter: groupId, Value: com.example [INFO] Parameter: artifactId, Value: mywebapp [INFO] project created from Archetype in dir: /your-dir/mywebapp [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------
-
You can now open the project using your favourite IDE.
For setting up a webapp based on the dd4t-2-java through your IDE, you will need to enter the following information:
-
Archetype GroupId=org.dd4t
-
Archetype ArtifactId=dd4t-web8-archetype
-
ArchetypeVersion=1.1
(note, for Tridion 2013 / 2011 use 'dd4t-spring-mvc-archetype' with version 1.6
- For Eclipse you need the m2eclipse plugin. A nice guide on how to fully integrate can be found here: http://www.theserverside.com/news/1363817/Introduction-to-m2eclipse
-- Alternatively, you can create an Eclipse project from the command line and import it as an existing project:
mvn eclipse:eclipse
- For IntelliJ IDEA, follow this guide: https://www.jetbrains.com/idea/help/add-archetype-dialog.html
Navigate to src/main/resources/WEB-INF/classes of your created webapp and configure the Tridion configuration files like you normally would.
In addition, configure the dd4t.properties file. The properties are self-explanatory.
If you do not want to use cache invalidation, open up src/main/resources/WEB-INF/classes/dispatcher-servlet.xml and change the following line:
<bean id="cacheProvider" class="org.dd4t.core.providers.EHCacheProvider" />
in to:
<bean id="cacheProvider" class="org.dd4t.providers.impl.NoCacheProvider" />
Next, comment out the entire following section:
<bean id="cacheMessageListener" class="org.dd4t.core.caching.jms.impl.JMSCacheMessageListener"/>
<bean id="jmsExceptionListener" class="org.dd4t.core.caching.jms.impl.JMSExceptionListener"/>
<bean id="jmsCacheMonitor" class="org.dd4t.core.caching.jms.impl.JMSCacheMonitor" />
<bean id="jmsTransportListener" class="org.dd4t.core.caching.jms.impl.JMSTransportListener"/>
<bean id="connectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory">
<property name="brokerURL" value="${jms.brokerUrl}"/>
<property name="userName" value="${jms.userName}"/>
<property name="password" value="${jms.password}"/>
<property name="exceptionListener" ref="jmsExceptionListener"/>
<property name="transportListener" ref="jmsTransportListener"/>
</bean>
<jms:listener-container container-type="default" destination-type="topic" connection-factory="connectionFactory" acknowledge="auto">
<jms:listener destination="${jms.topicName}" ref="cacheMessageListener" method="onMessage"/>
</jms:listener-container>
Your next step should be to create a normal web app run configuration in your IDE to run the application.