Skip to content

Instantly share code, notes, and snippets.

View darbyluv2code's full-sized avatar

Chad Darby darbyluv2code

View GitHub Profile
@darbyluv2code
darbyluv2code / pom.xml
Last active April 14, 2018 08:32
Maven POM: Spring MVC + Hibernate
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.luv2code</groupId>
<artifactId>spring-demo</artifactId>
<version>1.0</version>
<packaging>war</packaging>
<name>spring-demo</name>
@darbyluv2code
darbyluv2code / ReadStudentDemo.java
Created May 4, 2018 21:14
Hibernate: Update and Read with transactions
package com.luv2code.hibernate.demo;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
import com.luv2code.hibernate.demo.entity.Student;
public class ReadStudentDemo {
@darbyluv2code
darbyluv2code / pom.xml
Created May 9, 2018 14:14
Maven pom file for standalone spring core projects
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.luv2code</groupId>
<artifactId>spring-demo</artifactId>
<version>1.0.0</version>
<packaging>jar</packaging>
<properties>
<springframework.version>5.0.6.RELEASE</springframework.version>
@darbyluv2code
darbyluv2code / Student.java
Created May 12, 2018 17:14
Hibernate - Student.java constructors
package com.luv2code.hibernate.demo.entity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
@Entity
@darbyluv2code
darbyluv2code / hibernate config updates
Created May 16, 2018 23:06
Updates for hibernate config
Replace
<property name="connection.url">jdbc:mysql://localhost/hb_student_tracker?useSSL=false&useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC</property>
With
<property name="connection.url">jdbc:mysql://localhost/hb_student_tracker?useSSL=false&amp;useUnicode=true&amp;useJDBCCompliantTimezoneShift=true&amp;useLegacyDatetimeCode=false&amp;serverTimezone=UTC</property>
@darbyluv2code
darbyluv2code / applicationContext.xml
Created May 19, 2018 23:34
applicationContext.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.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd">
<!-- Define your beans here -->
@darbyluv2code
darbyluv2code / pom.xml
Created May 22, 2018 01:12
Web Customer Tracker - Maven POM file
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.luv2code.springdemo</groupId>
<artifactId>spring-web-customer-tracker</artifactId>
<version>1.0.0</version>
<packaging>war</packaging>
<properties>
<springframework.version>5.0.6.RELEASE</springframework.version>
@darbyluv2code
darbyluv2code / SecurityWebApplicationInitializer.java
Created June 6, 2018 21:13
Spring CRM REST - SecurityWebApplicationInitializer
package com.luv2code.springdemo.config;
import org.springframework.security.web.context.AbstractSecurityWebApplicationInitializer;
public class SecurityWebApplicationInitializer
extends AbstractSecurityWebApplicationInitializer {
}
@darbyluv2code
darbyluv2code / DemoSecurityConfig.java
Created June 6, 2018 21:15
Spring CRM REST - DemoSecurityConfig (basic)
package com.luv2code.springdemo.config;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.HttpMethod;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.config.http.SessionCreationPolicy;
import org.springframework.security.core.userdetails.User;
@darbyluv2code
darbyluv2code / DemoSecurityConfig.java
Last active September 18, 2021 18:02
DemoSecurityConfig.java (roles)
package com.luv2code.springdemo.config;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.HttpMethod;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.config.http.SessionCreationPolicy;