forked from Apress/pro-spring-5
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
96 started adding files for the boot example
- Loading branch information
Showing
35 changed files
with
769 additions
and
96 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ build | |
gradle | ||
gradlew* | ||
*.class | ||
transaction-logs | ||
|
||
# Mobile Tools for Java (J2ME) | ||
.mtj.tmp/ | ||
|
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
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
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
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
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
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
buildscript { | ||
repositories { | ||
mavenLocal() | ||
mavenCentral() | ||
maven { url "http://repo.spring.io/release" } | ||
maven { url "http://repo.spring.io/snapshot" } | ||
maven { url "https://repo.spring.io/libs-snapshot" } | ||
maven { url "http://repo.spring.io/milestone" } | ||
maven { url "https://repo.spring.io/libs-milestone" } | ||
} | ||
|
||
dependencies { | ||
classpath boot.springBootPlugin | ||
} | ||
} | ||
|
||
apply plugin: 'org.springframework.boot' | ||
|
||
dependencies { | ||
compile boot.starterJpa, boot.starterJta, db.h2, boot.starterWeb, boot.starterThyme, boot.starterSecurity | ||
testCompile boot.starterTest | ||
} | ||
|
||
jar { | ||
manifest { | ||
attributes("Created-By": "Iuliana Cosmina", | ||
"Specification-Title": "Pro Spring 5", | ||
"Main-Class" : "com.apress.prospring5.ch16.SingerApplication", | ||
"Class-Path": configurations.compile.collect { it.getName() }.join(' ')) | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
chapter16/singer-webapp-boot/src/main/java/com/apress/prospring5/ch16/SingerApplication.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.apress.prospring5.ch16; | ||
|
||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
import org.springframework.boot.SpringApplication; | ||
import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
import org.springframework.context.ConfigurableApplicationContext; | ||
|
||
/** | ||
* Created by iuliana.cosmina on 7/16/17. | ||
*/ | ||
@SpringBootApplication(scanBasePackages = {"com.apress.prospring5.ch16.web", "com.apress.prospring5.ch16.services"}) | ||
public class SingerApplication { | ||
|
||
private static Logger logger = LoggerFactory.getLogger(SingerApplication.class); | ||
|
||
public static void main(String... args) throws Exception { | ||
ConfigurableApplicationContext ctx = SpringApplication.run(SingerApplication.class, args); | ||
assert (ctx != null); | ||
logger.info("Application started..."); | ||
System.in.read(); | ||
ctx.close(); | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
chapter16/singer-webapp-boot/src/main/java/com/apress/prospring5/ch16/WebSecurityConfig.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package com.apress.prospring5.ch16; | ||
|
||
import org.springframework.context.annotation.Configuration; | ||
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; | ||
|
||
/** | ||
* Created by iuliana.cosmina on 7/16/17. | ||
*/ | ||
@Configuration | ||
@EnableWebSecurity | ||
public class WebSecurityConfig extends WebSecurityConfigurerAdapter { | ||
|
||
@Override | ||
protected void configure(HttpSecurity httpSecurity) throws Exception { | ||
httpSecurity.authorizeRequests().antMatchers("/").permitAll(); | ||
httpSecurity.csrf().disable(); | ||
httpSecurity.headers().frameOptions().disable(); | ||
} | ||
} |
123 changes: 123 additions & 0 deletions
123
chapter16/singer-webapp-boot/src/main/java/com/apress/prospring5/ch16/entities/Singer.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
package com.apress.prospring5.ch16.entities; | ||
|
||
|
||
import org.hibernate.validator.constraints.NotBlank; | ||
|
||
import javax.persistence.*; | ||
import javax.validation.constraints.NotNull; | ||
import javax.validation.constraints.Size; | ||
import java.io.Serializable; | ||
import java.text.SimpleDateFormat; | ||
import java.util.Date; | ||
|
||
import static javax.persistence.GenerationType.IDENTITY; | ||
|
||
@Entity | ||
@Table(name = "singer") | ||
public class Singer implements Serializable { | ||
@Id | ||
@GeneratedValue(strategy = IDENTITY) | ||
@Column(name = "ID") | ||
private Long id; | ||
|
||
@Version | ||
@Column(name = "VERSION") | ||
private int version; | ||
|
||
@NotBlank(message="{validation.firstname.NotBlank.message}") | ||
@Size(min=2, max=60, message="{validation.firstname.Size.message}") | ||
@Column(name = "FIRST_NAME") | ||
private String firstName; | ||
|
||
@NotBlank(message="{validation.lastname.NotBlank.message}") | ||
@Size(min=1, max=40, message="{validation.lastname.Size.message}") | ||
@Column(name = "LAST_NAME") | ||
private String lastName; | ||
|
||
@NotNull | ||
@Temporal(TemporalType.DATE) | ||
@Column(name = "BIRTH_DATE") | ||
private Date birthDate; | ||
|
||
@Column(name = "DESCRIPTION") | ||
private String description; | ||
|
||
@Basic(fetch= FetchType.LAZY) | ||
@Lob | ||
@Column(name = "PHOTO") | ||
private byte[] photo; | ||
|
||
|
||
public Long getId() { | ||
return id; | ||
} | ||
|
||
public int getVersion() { | ||
return version; | ||
} | ||
|
||
public String getFirstName() { | ||
return firstName; | ||
} | ||
|
||
|
||
public String getLastName() { | ||
return lastName; | ||
} | ||
|
||
public void setId(Long id) { | ||
this.id = id; | ||
} | ||
|
||
public void setVersion(int version) { | ||
this.version = version; | ||
} | ||
|
||
public void setFirstName(String firstName) { | ||
this.firstName = firstName; | ||
} | ||
|
||
public void setLastName(String lastName) { | ||
this.lastName = lastName; | ||
} | ||
|
||
public void setBirthDate(Date birthDate) { | ||
this.birthDate = birthDate; | ||
} | ||
|
||
public Date getBirthDate() { | ||
return birthDate; | ||
} | ||
|
||
public String getDescription() { | ||
return description; | ||
} | ||
|
||
public void setDescription(String description) { | ||
this.description = description; | ||
} | ||
|
||
public byte[] getPhoto() { | ||
return photo; | ||
} | ||
|
||
public void setPhoto(byte[] photo) { | ||
this.photo = photo; | ||
} | ||
@Transient | ||
public String getBirthDateString() { | ||
String birthDateString = ""; | ||
if (birthDate != null) { | ||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); | ||
birthDateString = sdf.format(birthDate); | ||
} | ||
return birthDateString; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "Singer - Id: " + id + ", First name: " + firstName | ||
+ ", Last name: " + lastName + ", Birthday: " + birthDate | ||
+ ", Description: " + description; | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
...6/singer-webapp-boot/src/main/java/com/apress/prospring5/ch16/repos/SingerRepository.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.apress.prospring5.ch16.repos; | ||
|
||
import com.apress.prospring5.ch16.entities.Singer; | ||
import org.springframework.data.repository.PagingAndSortingRepository; | ||
|
||
public interface SingerRepository extends PagingAndSortingRepository<Singer, Long> { | ||
} |
Oops, something went wrong.