Skip to content

Commit e7dcda8

Browse files
committed
Projeto do curso
1 parent bd82009 commit e7dcda8

File tree

1,058 files changed

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

1,058 files changed

+321223
-0
lines changed
Lines changed: 243 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,243 @@
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>1.0.0-SNAPSHOT</version>
9+
10+
<packaging>war</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.0.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.0</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+
</properties>
61+
62+
<build>
63+
<plugins>
64+
<plugin>
65+
<artifactId>maven-compiler-plugin</artifactId>
66+
<version>${maven-compiler-pluging.version}</version>
67+
<configuration>
68+
<source>${java.version}</source>
69+
<target>${java.version}</target>
70+
</configuration>
71+
</plugin>
72+
73+
<plugin>
74+
<groupId>org.flywaydb</groupId>
75+
<artifactId>flyway-maven-plugin</artifactId>
76+
<version>${flyway-maven-plugin.version}</version>
77+
<configuration>
78+
<driver>com.mysql.jdbc.Driver</driver>
79+
</configuration>
80+
</plugin>
81+
</plugins>
82+
</build>
83+
84+
<dependencyManagement>
85+
<dependencies>
86+
<dependency>
87+
<groupId>org.springframework</groupId>
88+
<artifactId>spring-framework-bom</artifactId>
89+
<version>${spring-framework.version}</version>
90+
<type>pom</type>
91+
<scope>import</scope>
92+
</dependency>
93+
</dependencies>
94+
</dependencyManagement>
95+
96+
<dependencies>
97+
<!-- Spring MVC -->
98+
<dependency>
99+
<groupId>org.springframework</groupId>
100+
<artifactId>spring-webmvc</artifactId>
101+
<scope>compile</scope>
102+
<exclusions>
103+
<exclusion>
104+
<groupId>commons-logging</groupId>
105+
<artifactId>commons-logging</artifactId>
106+
</exclusion>
107+
</exclusions>
108+
</dependency>
109+
110+
<!-- Servlet API -->
111+
<dependency>
112+
<groupId>javax.servlet</groupId>
113+
<artifactId>javax.servlet-api</artifactId>
114+
<version>${servlet.version}</version>
115+
<scope>provided</scope>
116+
</dependency>
117+
118+
<!-- Thymeleaf -->
119+
<dependency>
120+
<groupId>org.thymeleaf</groupId>
121+
<artifactId>thymeleaf</artifactId>
122+
<version>${thymeleaf.version}</version>
123+
<scope>compile</scope>
124+
</dependency>
125+
126+
<dependency>
127+
<groupId>org.thymeleaf</groupId>
128+
<artifactId>thymeleaf-spring4</artifactId>
129+
<version>${thymeleaf.version}</version>
130+
<scope>compile</scope>
131+
</dependency>
132+
133+
<!-- Bean Validation / Hibernate Validator -->
134+
<dependency>
135+
<groupId>org.hibernate</groupId>
136+
<artifactId>hibernate-validator</artifactId>
137+
<version>${hibernate-validator.version}</version>
138+
<scope>compile</scope>
139+
</dependency>
140+
141+
<!-- Thymeleaf - Layout Dialect -->
142+
<dependency>
143+
<groupId>nz.net.ultraq.thymeleaf</groupId>
144+
<artifactId>thymeleaf-layout-dialect</artifactId>
145+
<version>${thymeleaf-layout-dialect.version}</version>
146+
</dependency>
147+
148+
<!-- Logging -->
149+
<dependency>
150+
<groupId>org.apache.logging.log4j</groupId>
151+
<artifactId>log4j-slf4j-impl</artifactId>
152+
<version>${log4j.version}</version>
153+
</dependency>
154+
<dependency>
155+
<groupId>org.apache.logging.log4j</groupId>
156+
<artifactId>log4j-api</artifactId>
157+
<version>${log4j.version}</version>
158+
</dependency>
159+
<dependency>
160+
<groupId>org.apache.logging.log4j</groupId>
161+
<artifactId>log4j-core</artifactId>
162+
<version>${log4j.version}</version>
163+
</dependency>
164+
<dependency>
165+
<groupId>org.slf4j</groupId>
166+
<artifactId>jcl-over-slf4j</artifactId>
167+
<version>${jcl-over-slf4j.version}</version>
168+
</dependency>
169+
170+
<!-- JPA / Hibernate -->
171+
<dependency>
172+
<groupId>org.hibernate</groupId>
173+
<artifactId>hibernate-entitymanager</artifactId>
174+
<version>${hibernate.version}</version>
175+
<scope>compile</scope>
176+
</dependency>
177+
178+
<!-- Hibernate - Java 8 support -->
179+
<dependency>
180+
<groupId>org.hibernate</groupId>
181+
<artifactId>hibernate-java8</artifactId>
182+
<version>${hibernate.version}</version>
183+
<scope>compile</scope>
184+
</dependency>
185+
186+
<!-- MySQL Driver -->
187+
<dependency>
188+
<groupId>mysql</groupId>
189+
<artifactId>mysql-connector-java</artifactId>
190+
<version>${mysql-connector-java.version}</version>
191+
<scope>provided</scope>
192+
</dependency>
193+
194+
<!-- Spring Data JPA -->
195+
<dependency>
196+
<groupId>org.springframework.data</groupId>
197+
<artifactId>spring-data-jpa</artifactId>
198+
<version>${spring-data-jpa.version}</version>
199+
<scope>compile</scope>
200+
</dependency>
201+
202+
<!-- Jackson - JSON -->
203+
<dependency>
204+
<groupId>com.fasterxml.jackson.core</groupId>
205+
<artifactId>jackson-databind</artifactId>
206+
<version>${jackson-core.version}</version>
207+
<scope>compile</scope>
208+
</dependency>
209+
210+
<!-- thumbnailator - Gerar Thumbnail -->
211+
<dependency>
212+
<groupId>net.coobird</groupId>
213+
<artifactId>thumbnailator</artifactId>
214+
<version>${thumbnailator.version}</version>
215+
<scope>compile</scope>
216+
</dependency>
217+
218+
<!-- Thymeleaf extras data attribute -->
219+
<dependency>
220+
<groupId>com.github.mxab.thymeleaf.extras</groupId>
221+
<artifactId>thymeleaf-extras-data-attribute</artifactId>
222+
<version>${thymeleaf-extras-data-attribute.version}</version>
223+
<scope>compile</scope>
224+
</dependency>
225+
226+
<!-- Cache - Guava -->
227+
<dependency>
228+
<groupId>com.google.guava</groupId>
229+
<artifactId>guava</artifactId>
230+
<version>${guava.version}</version>
231+
<scope>compile</scope>
232+
</dependency>
233+
234+
<!-- Spring Context Support -->
235+
<dependency>
236+
<groupId>org.springframework</groupId>
237+
<artifactId>spring-context-support</artifactId>
238+
<scope>compile</scope>
239+
</dependency>
240+
241+
</dependencies>
242+
243+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
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.jdbc.datasource.lookup.JndiDataSourceLookup;
11+
import org.springframework.orm.jpa.JpaTransactionManager;
12+
import org.springframework.orm.jpa.JpaVendorAdapter;
13+
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
14+
import org.springframework.orm.jpa.vendor.Database;
15+
import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter;
16+
import org.springframework.transaction.PlatformTransactionManager;
17+
import org.springframework.transaction.annotation.EnableTransactionManagement;
18+
19+
import com.algaworks.brewer.model.Cerveja;
20+
import com.algaworks.brewer.repository.Cervejas;
21+
22+
@Configuration
23+
@ComponentScan(basePackageClasses = Cervejas.class)
24+
@EnableJpaRepositories(basePackageClasses = Cervejas.class, enableDefaultTransactions = false)
25+
@EnableTransactionManagement
26+
@ComponentScan(basePackageClasses = Cervejas.class)
27+
public class JPAConfig {
28+
29+
@Bean
30+
public DataSource dataSource() {
31+
JndiDataSourceLookup dataSourceLookup = new JndiDataSourceLookup();
32+
dataSourceLookup.setResourceRef(true);
33+
return dataSourceLookup.getDataSource("jdbc/brewerDB");
34+
}
35+
36+
@Bean
37+
public JpaVendorAdapter jpaVendorAdapter() {
38+
HibernateJpaVendorAdapter adapter = new HibernateJpaVendorAdapter();
39+
adapter.setDatabase(Database.MYSQL);
40+
adapter.setShowSql(false);
41+
adapter.setGenerateDdl(false);
42+
adapter.setDatabasePlatform("org.hibernate.dialect.MySQLDialect");
43+
return adapter;
44+
}
45+
46+
@Bean
47+
public EntityManagerFactory entityManagerFactory(DataSource dataSource, JpaVendorAdapter jpaVendorAdapter) {
48+
LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean();
49+
factory.setDataSource(dataSource);
50+
factory.setJpaVendorAdapter(jpaVendorAdapter);
51+
factory.setPackagesToScan(Cerveja.class.getPackage().getName());
52+
factory.afterPropertiesSet();
53+
return factory.getObject();
54+
}
55+
56+
@Bean
57+
public PlatformTransactionManager transactionManager(EntityManagerFactory entityManagerFactory) {
58+
JpaTransactionManager transactionManager = new JpaTransactionManager();
59+
transactionManager.setEntityManagerFactory(entityManagerFactory);
60+
return transactionManager;
61+
}
62+
63+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package com.algaworks.brewer.config;
2+
3+
import org.springframework.context.annotation.Bean;
4+
import org.springframework.context.annotation.ComponentScan;
5+
import org.springframework.context.annotation.Configuration;
6+
7+
import com.algaworks.brewer.service.CadastroCervejaService;
8+
import com.algaworks.brewer.storage.FotoStorage;
9+
import com.algaworks.brewer.storage.local.FotoStorageLocal;
10+
11+
@Configuration
12+
@ComponentScan(basePackageClasses = CadastroCervejaService.class)
13+
public class ServiceConfig {
14+
15+
@Bean
16+
public FotoStorage fotoStorage() {
17+
return new FotoStorageLocal();
18+
}
19+
20+
}

0 commit comments

Comments
 (0)