Review
In the previous section, we have implemented the Java classes. In this section, we will start writing the configuration files to complete our Spring application.Table of Contents
Part 1: Introduction and Functional SpecsPart 2: SendGrid account setup
Part 3: Java classes
Part 4: XML configuration
Part 5: Running the Application
Configuration
To complete our application, here are the important configuration files that needs to be declared:- spring.properties
- applicationContext.xml
- spring-servlet.xml
- web.xml
The spring.properties file contains the SendGrid user and key values to access the Web API. This is equivalent to your SendGrid's username and password.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# SendGrid properties | |
sendgrid.api.user=YOUR-USER-API | |
sendgrid.api.key=YOUR-KEY-API |
applicationContext.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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" | |
xmlns:mvc="http://www.springframework.org/schema/mvc" | |
xsi:schemaLocation="http://www.springframework.org/schema/beans | |
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd | |
http://www.springframework.org/schema/context | |
http://www.springframework.org/schema/context/spring-context-3.1.xsd | |
http://www.springframework.org/schema/mvc | |
http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd"> | |
<context:property-placeholder properties-ref="deployProperties" /> | |
<!-- Activates various annotations to be detected in bean classes --> | |
<context:annotation-config /> | |
<!-- Scans the classpath for annotated components that will be auto-registered as Spring beans. | |
For example @Controller and @Service. Make sure to set the correct base-package --> | |
<context:component-scan base-package="org.krams" /> | |
<!-- Configures the annotation-driven Spring MVC Controller programming model. | |
Note that, with Spring 3.0, this tag works in Servlet MVC only! --> | |
<mvc:annotation-driven /> | |
<mvc:resources mapping="/resources/**" location="/resources/" /> | |
<!-- Imports logging configuration --> | |
<import resource="trace-context.xml"/> | |
<bean id="deployProperties" class="org.springframework.beans.factory.config.PropertiesFactoryBean" | |
p:location="/WEB-INF/spring.properties" /> | |
</beans> |
spring-servlet.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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:p="http://www.springframework.org/schema/p" | |
xsi:schemaLocation="http://www.springframework.org/schema/beans | |
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd"> | |
<!-- Declare a view resolver --> | |
<bean id="jspViewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver" | |
p:prefix="/WEB-INF/jsp/" p:suffix=".jsp" p:order="1"/> | |
</beans> |
web.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<web-app id="WebApp_ID" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"> | |
<display-name>Spring SendGrid Tutorial</display-name> | |
<listener> | |
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> | |
</listener> | |
<servlet> | |
<servlet-name>spring</servlet-name> | |
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> | |
</servlet> | |
<servlet-mapping> | |
<servlet-name>spring</servlet-name> | |
<url-pattern>/</url-pattern> | |
</servlet-mapping> | |
</web-app> |
Next
In the next section, we will build and run the application using Maven, and show how to import the project in Eclipse. Click here to proceed.
Share the joy:
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |


I have read your blog its very attractive and impressive. I like it your blog.
ReplyDeleteSpring online training Spring online training Spring Hibernate online training Spring Hibernate online training Java online training
spring training in chennai spring hibernate training in chennai
I enjoyed your blog Thanks for sharing such an informative post. We are also providing the best services click on below links to visit our website.
ReplyDeletedigital marketing company in nagercoil
digital marketing services in nagercoil
digital marketing agency in nagercoil
best marketing services in nagercoil
SEO company in nagercoil
SEO services in nagercoil
social media marketing in nagercoil
social media company in nagercoil
PPC services in nagercoil
digital marketing company in velachery
digital marketing company in velachery
digital marketing services in velachery
digital marketing agency in velachery
SEO company in velachery
SEO services in velachery
social media marketing in velachery
social media company in velachery
PPC services in velachery
online advertisement services in velachery
online advertisement services in nagercoil
web design company in nagercoil
web development company in nagercoil
website design company in nagercoil
website development company in nagercoil
web designing company in nagercoil
website designing company in nagercoil
best web design company in nagercoil
web design company in velachery
web development company in velachery
website design company in velachery
website development company in velachery
web designing company in velachery
website designing company in velachery
best web design company in velachery
Thanks for Sharing - ( Groarz branding solutions )