Skip to content

Commit 52decb7

Browse files
committed
Adding all files
0 parents  commit 52decb7

File tree

94 files changed

+22101
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

94 files changed

+22101
-0
lines changed

.classpath

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<classpath>
3+
<classpathentry kind="src" output="target/classes" path="src/main/java">
4+
<attributes>
5+
<attribute name="optional" value="true"/>
6+
<attribute name="maven.pomderived" value="true"/>
7+
</attributes>
8+
</classpathentry>
9+
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
10+
<attributes>
11+
<attribute name="optional" value="true"/>
12+
<attribute name="maven.pomderived" value="true"/>
13+
</attributes>
14+
</classpathentry>
15+
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7">
16+
<attributes>
17+
<attribute name="maven.pomderived" value="true"/>
18+
</attributes>
19+
</classpathentry>
20+
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
21+
<attributes>
22+
<attribute name="maven.pomderived" value="true"/>
23+
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
24+
</attributes>
25+
</classpathentry>
26+
<classpathentry kind="output" path="target/classes"/>
27+
</classpath>

.project

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>spring-mvc-breadcrumb</name>
4+
<comment></comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>org.eclipse.jdt.core.javabuilder</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
<buildCommand>
14+
<name>org.eclipse.wst.common.project.facet.core.builder</name>
15+
<arguments>
16+
</arguments>
17+
</buildCommand>
18+
<buildCommand>
19+
<name>org.eclipse.m2e.core.maven2Builder</name>
20+
<arguments>
21+
</arguments>
22+
</buildCommand>
23+
<buildCommand>
24+
<name>org.eclipse.wst.validation.validationbuilder</name>
25+
<arguments>
26+
</arguments>
27+
</buildCommand>
28+
</buildSpec>
29+
<natures>
30+
<nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
31+
<nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
32+
<nature>org.eclipse.jdt.core.javanature</nature>
33+
<nature>org.eclipse.m2e.core.maven2Nature</nature>
34+
<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
35+
<nature>org.eclipse.wst.jsdt.core.jsNature</nature>
36+
</natures>
37+
</projectDescription>

.settings/.jsdtscope

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<classpath>
3+
<classpathentry kind="src" path="src/main/webapp"/>
4+
<classpathentry excluding="**/bower_components/*|**/node_modules/*|**/*.min.js" kind="src" path="target/m2e-wtp/web-resources"/>
5+
<classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.JRE_CONTAINER"/>
6+
<classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.WebProject">
7+
<attributes>
8+
<attribute name="hide" value="true"/>
9+
</attributes>
10+
</classpathentry>
11+
<classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.baseBrowserLibrary"/>
12+
<classpathentry kind="output" path=""/>
13+
</classpath>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
eclipse.preferences.version=1
2+
encoding/<project>=UTF-8

.settings/org.eclipse.jdt.core.prefs

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
eclipse.preferences.version=1
2+
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
3+
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
4+
org.eclipse.jdt.core.compiler.compliance=1.7
5+
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
6+
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
7+
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
8+
org.eclipse.jdt.core.compiler.source=1.7

.settings/org.eclipse.m2e.core.prefs

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
activeProfiles=
2+
eclipse.preferences.version=1
3+
resolveWorkspaceProjects=true
4+
version=1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
2+
<wb-module deploy-name="spring-mvc-breadcrumb">
3+
<wb-resource deploy-path="/" source-path="/target/m2e-wtp/web-resources"/>
4+
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
5+
<property name="context-root" value="spring-mvc-breadcrumb"/>
6+
<property name="java-output-path" value="/spring-mvc-breadcrumb/target/classes"/>
7+
</wb-module>
8+
</project-modules>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<faceted-project>
3+
<fixed facet="wst.jsdt.web"/>
4+
<installed facet="java" version="1.7"/>
5+
<installed facet="jst.web" version="2.3"/>
6+
<installed facet="wst.jsdt.web" version="1.0"/>
7+
</faceted-project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
org.eclipse.wst.jsdt.launching.baseBrowserLibrary
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Window
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
disabled=06target
2+
eclipse.preferences.version=1

pom.xml

+99
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
7+
<groupId>com.tutorial.spring</groupId>
8+
<artifactId>spring-mvc-breadcrumb</artifactId>
9+
<version>0.0.1-SNAPSHOT</version>
10+
<packaging>war</packaging>
11+
12+
<name>spring-mvc-breadcrumb Maven Webapp</name>
13+
14+
<properties>
15+
<java.version>1.8</java.version>
16+
<spring.version>4.0.3.RELEASE</spring.version>
17+
</properties>
18+
19+
<dependencies>
20+
<!-- Spring core & mvc -->
21+
<dependency>
22+
<groupId>org.springframework</groupId>
23+
<artifactId>spring-context</artifactId>
24+
<version>${spring.version}</version>
25+
</dependency>
26+
27+
<dependency>
28+
<groupId>org.springframework</groupId>
29+
<artifactId>spring-webmvc</artifactId>
30+
<version>${spring.version}</version>
31+
</dependency>
32+
<dependency>
33+
<groupId>org.springframework</groupId>
34+
<artifactId>spring-orm</artifactId>
35+
<version>${spring.version}</version>
36+
<type>jar</type>
37+
<scope>compile</scope>
38+
</dependency>
39+
40+
<!-- jsp/servlet -->
41+
<dependency>
42+
<groupId>javax.servlet</groupId>
43+
<artifactId>javax.servlet-api</artifactId>
44+
<version>3.1.0</version>
45+
<scope>provided</scope>
46+
</dependency>
47+
<dependency>
48+
<groupId>javax.servlet.jsp</groupId>
49+
<artifactId>javax.servlet.jsp-api</artifactId>
50+
<version>2.3.1</version>
51+
<scope>provided</scope>
52+
</dependency>
53+
<dependency>
54+
<groupId>jstl</groupId>
55+
<artifactId>jstl</artifactId>
56+
<version>1.2</version>
57+
</dependency>
58+
59+
<!-- mysql -->
60+
<dependency>
61+
<groupId>mysql</groupId>
62+
<artifactId>mysql-connector-java</artifactId>
63+
<version>8.0.11</version>
64+
</dependency>
65+
66+
<dependency>
67+
<groupId>org.apache.commons</groupId>
68+
<artifactId>commons-lang3</artifactId>
69+
<version>3.7</version>
70+
</dependency>
71+
</dependencies>
72+
73+
<build>
74+
<finalName>spring-mvc-breadcrumb</finalName>
75+
<pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
76+
<plugins>
77+
<plugin>
78+
<groupId>org.apache.maven.plugins</groupId>
79+
<artifactId>maven-compiler-plugin</artifactId>
80+
<version>2.0.2</version>
81+
<configuration>
82+
<source>${java.version}</source>
83+
<target>${java.version}</target>
84+
</configuration>
85+
</plugin>
86+
<!-- For Maven Tomcat Plugin -->
87+
<plugin>
88+
<groupId>org.apache.tomcat.maven</groupId>
89+
<artifactId>tomcat7-maven-plugin</artifactId>
90+
<version>2.2</version>
91+
<configuration>
92+
<port>8081</port>
93+
<path>/</path>
94+
</configuration>
95+
</plugin>
96+
</plugins>
97+
</pluginManagement>
98+
</build>
99+
</project>

sql/employee.sql

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
-- Adminer 4.6.2 MySQL dump
2+
3+
SET NAMES utf8;
4+
SET time_zone = '+00:00';
5+
6+
CREATE DATABASE `employee` /*!40100 DEFAULT CHARACTER SET utf8 */;
7+
USE `employee`;
8+
9+
CREATE TABLE `breadcrumb_details` (
10+
`id` int(11) NOT NULL AUTO_INCREMENT,
11+
`fk_parent_breadcrumb_id` int(11) DEFAULT NULL,
12+
`title` varchar(100) DEFAULT NULL,
13+
`url` varchar(250) DEFAULT NULL,
14+
PRIMARY KEY (`id`)
15+
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
16+
17+
18+
CREATE TABLE `employee` (
19+
`id` int(11) NOT NULL AUTO_INCREMENT,
20+
`name` varchar(50) NOT NULL,
21+
`email` varchar(250) NOT NULL,
22+
`address` text NOT NULL,
23+
`telephone` varchar(20) NOT NULL,
24+
PRIMARY KEY (`id`)
25+
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
26+
27+
28+
-- 2019-09-28 11:33:29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package com.tutorial.spring.config;
2+
3+
import org.springframework.beans.BeansException;
4+
import org.springframework.context.ApplicationContext;
5+
import org.springframework.context.ApplicationContextAware;
6+
import org.springframework.stereotype.Component;
7+
8+
@Component
9+
public class ApplicationContextProvider implements ApplicationContextAware {
10+
11+
private static ApplicationContext context;
12+
13+
/**
14+
* Returns the Spring managed bean instance of the given class type if it exists.
15+
* Returns null otherwise.
16+
* @param beanClass
17+
* @return
18+
*/
19+
public static <T extends Object> T getBean(Class<T> beanClass) {
20+
return context.getBean(beanClass);
21+
}
22+
23+
@Override
24+
public void setApplicationContext(ApplicationContext context) throws BeansException {
25+
26+
// store ApplicationContext reference to access required beans later on
27+
ApplicationContextProvider.context = context;
28+
}
29+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
package com.tutorial.spring.config;
2+
3+
import javax.sql.DataSource;
4+
5+
import org.springframework.context.annotation.Bean;
6+
import org.springframework.context.annotation.ComponentScan;
7+
import org.springframework.context.annotation.Configuration;
8+
import org.springframework.jdbc.datasource.DriverManagerDataSource;
9+
import org.springframework.web.servlet.ViewResolver;
10+
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
11+
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
12+
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
13+
import org.springframework.web.servlet.view.InternalResourceViewResolver;
14+
15+
import com.tutorial.spring.dao.BreadcrumbDAO;
16+
import com.tutorial.spring.dao.BreadcrumbDAOImpl;
17+
import com.tutorial.spring.dao.EmployeeManagementDAO;
18+
import com.tutorial.spring.dao.EmployeeManagementDAOImpl;
19+
20+
@Configuration
21+
@ComponentScan(basePackages="net.codejava.spring.*")
22+
@EnableWebMvc
23+
public class MvcConfiguration extends WebMvcConfigurerAdapter{
24+
25+
@Bean
26+
public ViewResolver getViewResolver(){
27+
InternalResourceViewResolver resolver = new InternalResourceViewResolver();
28+
resolver.setPrefix("/WEB-INF/views/");
29+
resolver.setSuffix(".jsp");
30+
return resolver;
31+
}
32+
33+
@Override
34+
public void addResourceHandlers(ResourceHandlerRegistry registry) {
35+
registry.addResourceHandler("/resources/**").addResourceLocations("/resources/");
36+
}
37+
38+
@Bean
39+
public DataSource getDataSource() {
40+
DriverManagerDataSource dataSource = new DriverManagerDataSource();
41+
dataSource.setDriverClassName("com.mysql.jdbc.Driver");
42+
dataSource.setUrl("jdbc:mysql://localhost:8889/employee");
43+
dataSource.setUsername("root");
44+
dataSource.setPassword("root");
45+
46+
return dataSource;
47+
}
48+
49+
@Bean
50+
public EmployeeManagementDAO getEmployeeManagementDAO() {
51+
return new EmployeeManagementDAOImpl(getDataSource());
52+
}
53+
54+
@Bean
55+
public BreadcrumbDAO getBreadcrumbDAO() {
56+
return new BreadcrumbDAOImpl(getDataSource());
57+
}
58+
}

0 commit comments

Comments
 (0)