Skip to content

Commit ecc2991

Browse files
committed
Projeto do curso
1 parent 9f0bf06 commit ecc2991

File tree

238 files changed

+50496
-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.

238 files changed

+50496
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
web: java $JAVA_OPTS -Dspring.profiles.active=prod -jar target/dependency/webapp-runner.jar --port $PORT target/*.war
Lines changed: 214 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,214 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3+
4+
<modelVersion>4.0.0</modelVersion>
5+
6+
<groupId>com.algaworks</groupId>
7+
<artifactId>brewer</artifactId>
8+
<version>2.0.0-SNAPSHOT</version>
9+
10+
<packaging>jar</packaging>
11+
12+
<properties>
13+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
14+
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
15+
16+
<failOnMissingWebXml>false</failOnMissingWebXml>
17+
18+
<java.version>1.8</java.version>
19+
<maven-compiler-pluging.version>3.2</maven-compiler-pluging.version>
20+
<flyway-maven-plugin.version>4.0.2</flyway-maven-plugin.version>
21+
<mysql-connector-java.version>5.1.39</mysql-connector-java.version>
22+
23+
<!-- Spring MVC -->
24+
<spring-framework.version>4.3.0.RELEASE</spring-framework.version>
25+
26+
<!-- Servlet API -->
27+
<servlet.version>3.1.0</servlet.version>
28+
29+
<!-- Thymeleaf -->
30+
<thymeleaf.version>3.0.1.RELEASE</thymeleaf.version>
31+
32+
<!-- Bean Validation / Hibernate Validator -->
33+
<hibernate-validator.version>5.2.4.Final</hibernate-validator.version>
34+
35+
<!-- Thymeleaf - Layout Dialect -->
36+
<thymeleaf-layout-dialect.version>2.0.1</thymeleaf-layout-dialect.version>
37+
38+
<!-- Logging -->
39+
<log4j.version>2.6</log4j.version>
40+
<jcl-over-slf4j.version>1.7.21</jcl-over-slf4j.version>
41+
42+
<!-- JPA / Hibernate -->
43+
<hibernate.version>5.1.0.Final</hibernate.version>
44+
45+
<!-- Spring Data JPA -->
46+
<spring-data-jpa.version>1.10.2.RELEASE</spring-data-jpa.version>
47+
48+
<!-- Jackson - JSON -->
49+
<jackson-core.version>2.7.5</jackson-core.version>
50+
51+
<!-- thumbnailator - Gerar Thumbnail -->
52+
<!-- https://github.com/coobird/thumbnailator -->
53+
<thumbnailator.version>0.4.8</thumbnailator.version>
54+
55+
<!-- Thymeleaf extras data attribute -->
56+
<thymeleaf-extras-data-attribute.version>2.0.1</thymeleaf-extras-data-attribute.version>
57+
58+
<!-- Cache - Guava -->
59+
<guava.version>19.0</guava.version>
60+
61+
<!-- Apache Bean Utils -->
62+
<commons-beanutils.version>1.9.2</commons-beanutils.version>
63+
64+
<!-- Spring Security -->
65+
<spring-security.version>4.1.1.RELEASE</spring-security.version>
66+
67+
<!-- Thymeleaf - Extras Spring Security -->
68+
<thymeleaf-extras-springsecurity4.version>3.0.0.RELEASE</thymeleaf-extras-springsecurity4.version>
69+
70+
<!-- JUnit -->
71+
<junit.version>4.12</junit.version>
72+
73+
<!-- Java Mail -->
74+
<javax.mail.version>1.5.6</javax.mail.version>
75+
76+
<!-- Apache Commons DBCP -->
77+
<commons-dbcp2.version>2.1.1</commons-dbcp2.version>
78+
79+
<!-- JasperReports -->
80+
<jasperreports.version>6.3.0</jasperreports.version>
81+
82+
<!-- JasperReports Fonts -->
83+
<jasperreports-fonts.version>6.0.0</jasperreports-fonts.version>
84+
</properties>
85+
86+
<build>
87+
<plugins>
88+
<plugin>
89+
<groupId>org.springframework.boot</groupId>
90+
<artifactId>spring-boot-maven-plugin</artifactId>
91+
</plugin>
92+
</plugins>
93+
</build>
94+
95+
<parent>
96+
<groupId>org.springframework.boot</groupId>
97+
<artifactId>spring-boot-starter-parent</artifactId>
98+
<version>1.4.1.RELEASE</version>
99+
</parent>
100+
101+
<dependencies>
102+
<dependency>
103+
<groupId>org.springframework.boot</groupId>
104+
<artifactId>spring-boot-starter-web</artifactId>
105+
<!-- Para o SLF4J ter soh um binding -->
106+
<exclusions>
107+
<exclusion>
108+
<artifactId>logback-classic</artifactId>
109+
<groupId>ch.qos.logback</groupId>
110+
</exclusion>
111+
</exclusions>
112+
</dependency>
113+
114+
<dependency>
115+
<groupId>org.springframework.boot</groupId>
116+
<artifactId>spring-boot-starter-data-jpa</artifactId>
117+
</dependency>
118+
119+
<dependency>
120+
<groupId>org.springframework.boot</groupId>
121+
<artifactId>spring-boot-starter-security</artifactId>
122+
</dependency>
123+
124+
<dependency>
125+
<groupId>org.springframework.boot</groupId>
126+
<artifactId>spring-boot-starter-thymeleaf</artifactId>
127+
</dependency>
128+
129+
<dependency>
130+
<groupId>org.springframework.boot</groupId>
131+
<artifactId>spring-boot-starter-mail</artifactId>
132+
</dependency>
133+
134+
<dependency>
135+
<groupId>mysql</groupId>
136+
<artifactId>mysql-connector-java</artifactId>
137+
<scope>runtime</scope>
138+
</dependency>
139+
140+
<dependency>
141+
<groupId>org.thymeleaf.extras</groupId>
142+
<artifactId>thymeleaf-extras-springsecurity4</artifactId>
143+
</dependency>
144+
145+
<dependency>
146+
<groupId>com.github.mxab.thymeleaf.extras</groupId>
147+
<artifactId>thymeleaf-extras-data-attribute</artifactId>
148+
</dependency>
149+
150+
<dependency>
151+
<groupId>org.springframework.boot</groupId>
152+
<artifactId>spring-boot-starter-log4j2</artifactId>
153+
</dependency>
154+
155+
<dependency>
156+
<groupId>com.google.guava</groupId>
157+
<artifactId>guava</artifactId>
158+
<version>${guava.version}</version>
159+
</dependency>
160+
161+
<dependency>
162+
<groupId>org.apache.commons</groupId>
163+
<artifactId>commons-dbcp2</artifactId>
164+
</dependency>
165+
166+
<dependency>
167+
<groupId>net.coobird</groupId>
168+
<artifactId>thumbnailator</artifactId>
169+
<version>${thumbnailator.version}</version>
170+
<scope>compile</scope>
171+
</dependency>
172+
173+
<dependency>
174+
<groupId>commons-beanutils</groupId>
175+
<artifactId>commons-beanutils</artifactId>
176+
</dependency>
177+
178+
<dependency>
179+
<groupId>junit</groupId>
180+
<artifactId>junit</artifactId>
181+
<scope>test</scope>
182+
</dependency>
183+
184+
<dependency>
185+
<groupId>org.flywaydb</groupId>
186+
<artifactId>flyway-core</artifactId>
187+
</dependency>
188+
189+
<dependency>
190+
<groupId>org.springframework.boot</groupId>
191+
<artifactId>spring-boot-devtools</artifactId>
192+
</dependency>
193+
194+
<dependency>
195+
<groupId>org.hibernate</groupId>
196+
<artifactId>hibernate-java8</artifactId>
197+
</dependency>
198+
199+
<dependency>
200+
<groupId>net.sf.jasperreports</groupId>
201+
<artifactId>jasperreports</artifactId>
202+
<version>${jasperreports.version}</version>
203+
<scope>compile</scope>
204+
</dependency>
205+
<dependency>
206+
<groupId>net.sf.jasperreports</groupId>
207+
<artifactId>jasperreports-fonts</artifactId>
208+
<version>${jasperreports-fonts.version}</version>
209+
<scope>compile</scope>
210+
</dependency>
211+
212+
</dependencies>
213+
214+
</project>
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package com.algaworks.brewer;
2+
3+
import java.util.Locale;
4+
5+
import org.springframework.boot.SpringApplication;
6+
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
7+
import org.springframework.boot.autoconfigure.SpringBootApplication;
8+
import org.springframework.context.annotation.Bean;
9+
import org.springframework.web.servlet.LocaleResolver;
10+
import org.springframework.web.servlet.i18n.FixedLocaleResolver;
11+
12+
@SpringBootApplication
13+
@EnableAutoConfiguration
14+
public class BrewerApplication {
15+
16+
public static void main(String[] args) {
17+
SpringApplication.run(BrewerApplication.class, args);
18+
}
19+
20+
@Bean
21+
public LocaleResolver localeResolver() {
22+
return new FixedLocaleResolver(new Locale("pt", "BR"));
23+
}
24+
25+
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
package com.algaworks.brewer.config;
2+
3+
import javax.persistence.EntityManagerFactory;
4+
import javax.sql.DataSource;
5+
6+
import org.springframework.context.annotation.Bean;
7+
import org.springframework.context.annotation.ComponentScan;
8+
import org.springframework.context.annotation.Configuration;
9+
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
10+
import org.springframework.orm.jpa.JpaTransactionManager;
11+
import org.springframework.orm.jpa.JpaVendorAdapter;
12+
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
13+
import org.springframework.orm.jpa.vendor.Database;
14+
import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter;
15+
import org.springframework.transaction.PlatformTransactionManager;
16+
import org.springframework.transaction.annotation.EnableTransactionManagement;
17+
18+
import com.algaworks.brewer.model.Cerveja;
19+
import com.algaworks.brewer.repository.Cervejas;
20+
21+
@Configuration
22+
@ComponentScan(basePackageClasses = Cervejas.class)
23+
@EnableJpaRepositories(basePackageClasses = Cervejas.class, enableDefaultTransactions = false)
24+
@EnableTransactionManagement
25+
public class JPAConfig {
26+
27+
@Bean
28+
public JpaVendorAdapter jpaVendorAdapter() {
29+
HibernateJpaVendorAdapter adapter = new HibernateJpaVendorAdapter();
30+
adapter.setDatabase(Database.MYSQL);
31+
adapter.setShowSql(false);
32+
adapter.setGenerateDdl(false);
33+
adapter.setDatabasePlatform("org.hibernate.dialect.MySQLDialect");
34+
return adapter;
35+
}
36+
37+
@Bean
38+
public EntityManagerFactory entityManagerFactory(DataSource dataSource, JpaVendorAdapter jpaVendorAdapter) {
39+
LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean();
40+
factory.setDataSource(dataSource);
41+
factory.setJpaVendorAdapter(jpaVendorAdapter);
42+
factory.setPackagesToScan(Cerveja.class.getPackage().getName());
43+
factory.setMappingResources("sql/consultas-nativas.xml");
44+
factory.afterPropertiesSet();
45+
return factory.getObject();
46+
}
47+
48+
@Bean
49+
public PlatformTransactionManager transactionManager(EntityManagerFactory entityManagerFactory) {
50+
JpaTransactionManager transactionManager = new JpaTransactionManager();
51+
transactionManager.setEntityManagerFactory(entityManagerFactory);
52+
return transactionManager;
53+
}
54+
55+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
package com.algaworks.brewer.config;
2+
3+
import java.util.Properties;
4+
5+
import org.springframework.beans.factory.annotation.Autowired;
6+
import org.springframework.context.annotation.Bean;
7+
import org.springframework.context.annotation.Configuration;
8+
import org.springframework.context.annotation.PropertySource;
9+
import org.springframework.core.env.Environment;
10+
import org.springframework.mail.javamail.JavaMailSender;
11+
import org.springframework.mail.javamail.JavaMailSenderImpl;
12+
13+
@Configuration
14+
@PropertySource(value = { "classpath:env/mail-${ambiente:local}.properties" })
15+
@PropertySource(value = { "file://${HOME}/.brewer-mail.properties" }, ignoreResourceNotFound = true)
16+
public class MailConfig {
17+
18+
@Autowired
19+
private Environment env;
20+
21+
@Bean
22+
public JavaMailSender mailSender() {
23+
JavaMailSenderImpl mailSender = new JavaMailSenderImpl();
24+
mailSender.setHost("smtp.sendgrid.net");
25+
mailSender.setPort(587);
26+
mailSender.setUsername(env.getProperty("username"));
27+
mailSender.setPassword(env.getProperty("SENDGRID_PASSWORD"));
28+
29+
Properties props = new Properties();
30+
props.put("mail.transport.protocol", "smtp");
31+
props.put("mail.smtp.auth", true);
32+
props.put("mail.smtp.starttls.enable", true);
33+
props.put("mail.debug", false);
34+
props.put("mail.smtp.connectiontimeout", 10000); // miliseconds
35+
36+
mailSender.setJavaMailProperties(props);
37+
38+
return mailSender;
39+
}
40+
41+
}

0 commit comments

Comments
 (0)