Skip to content

Commit bd82009

Browse files
committed
Projeto do curso
1 parent b3f5ee8 commit bd82009

File tree

420 files changed

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

420 files changed

+136089
-0
lines changed
Lines changed: 225 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,225 @@
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+
</properties>
58+
59+
<build>
60+
<plugins>
61+
<plugin>
62+
<artifactId>maven-compiler-plugin</artifactId>
63+
<version>${maven-compiler-pluging.version}</version>
64+
<configuration>
65+
<source>${java.version}</source>
66+
<target>${java.version}</target>
67+
</configuration>
68+
</plugin>
69+
70+
<plugin>
71+
<groupId>org.flywaydb</groupId>
72+
<artifactId>flyway-maven-plugin</artifactId>
73+
<version>${flyway-maven-plugin.version}</version>
74+
<configuration>
75+
<driver>com.mysql.jdbc.Driver</driver>
76+
</configuration>
77+
</plugin>
78+
</plugins>
79+
</build>
80+
81+
<dependencyManagement>
82+
<dependencies>
83+
<dependency>
84+
<groupId>org.springframework</groupId>
85+
<artifactId>spring-framework-bom</artifactId>
86+
<version>${spring-framework.version}</version>
87+
<type>pom</type>
88+
<scope>import</scope>
89+
</dependency>
90+
</dependencies>
91+
</dependencyManagement>
92+
93+
<dependencies>
94+
<!-- Spring MVC -->
95+
<dependency>
96+
<groupId>org.springframework</groupId>
97+
<artifactId>spring-webmvc</artifactId>
98+
<scope>compile</scope>
99+
<exclusions>
100+
<exclusion>
101+
<groupId>commons-logging</groupId>
102+
<artifactId>commons-logging</artifactId>
103+
</exclusion>
104+
</exclusions>
105+
</dependency>
106+
107+
<!-- Servlet API -->
108+
<dependency>
109+
<groupId>javax.servlet</groupId>
110+
<artifactId>javax.servlet-api</artifactId>
111+
<version>${servlet.version}</version>
112+
<scope>provided</scope>
113+
</dependency>
114+
115+
<!-- Thymeleaf -->
116+
<dependency>
117+
<groupId>org.thymeleaf</groupId>
118+
<artifactId>thymeleaf</artifactId>
119+
<version>${thymeleaf.version}</version>
120+
<scope>compile</scope>
121+
</dependency>
122+
123+
<dependency>
124+
<groupId>org.thymeleaf</groupId>
125+
<artifactId>thymeleaf-spring4</artifactId>
126+
<version>${thymeleaf.version}</version>
127+
<scope>compile</scope>
128+
</dependency>
129+
130+
<!-- Bean Validation / Hibernate Validator -->
131+
<dependency>
132+
<groupId>org.hibernate</groupId>
133+
<artifactId>hibernate-validator</artifactId>
134+
<version>${hibernate-validator.version}</version>
135+
<scope>compile</scope>
136+
</dependency>
137+
138+
<!-- Thymeleaf - Layout Dialect -->
139+
<dependency>
140+
<groupId>nz.net.ultraq.thymeleaf</groupId>
141+
<artifactId>thymeleaf-layout-dialect</artifactId>
142+
<version>${thymeleaf-layout-dialect.version}</version>
143+
</dependency>
144+
145+
<!-- Logging -->
146+
<dependency>
147+
<groupId>org.apache.logging.log4j</groupId>
148+
<artifactId>log4j-slf4j-impl</artifactId>
149+
<version>${log4j.version}</version>
150+
</dependency>
151+
<dependency>
152+
<groupId>org.apache.logging.log4j</groupId>
153+
<artifactId>log4j-api</artifactId>
154+
<version>${log4j.version}</version>
155+
</dependency>
156+
<dependency>
157+
<groupId>org.apache.logging.log4j</groupId>
158+
<artifactId>log4j-core</artifactId>
159+
<version>${log4j.version}</version>
160+
</dependency>
161+
<dependency>
162+
<groupId>org.slf4j</groupId>
163+
<artifactId>jcl-over-slf4j</artifactId>
164+
<version>${jcl-over-slf4j.version}</version>
165+
</dependency>
166+
167+
<!-- JPA / Hibernate -->
168+
<dependency>
169+
<groupId>org.hibernate</groupId>
170+
<artifactId>hibernate-entitymanager</artifactId>
171+
<version>${hibernate.version}</version>
172+
<scope>compile</scope>
173+
</dependency>
174+
175+
<!-- Hibernate - Java 8 support -->
176+
<dependency>
177+
<groupId>org.hibernate</groupId>
178+
<artifactId>hibernate-java8</artifactId>
179+
<version>${hibernate.version}</version>
180+
<scope>compile</scope>
181+
</dependency>
182+
183+
<!-- MySQL Driver -->
184+
<dependency>
185+
<groupId>mysql</groupId>
186+
<artifactId>mysql-connector-java</artifactId>
187+
<version>${mysql-connector-java.version}</version>
188+
<scope>provided</scope>
189+
</dependency>
190+
191+
<!-- Spring Data JPA -->
192+
<dependency>
193+
<groupId>org.springframework.data</groupId>
194+
<artifactId>spring-data-jpa</artifactId>
195+
<version>${spring-data-jpa.version}</version>
196+
<scope>compile</scope>
197+
</dependency>
198+
199+
<!-- Jackson - JSON -->
200+
<dependency>
201+
<groupId>com.fasterxml.jackson.core</groupId>
202+
<artifactId>jackson-databind</artifactId>
203+
<version>${jackson-core.version}</version>
204+
<scope>compile</scope>
205+
</dependency>
206+
207+
<!-- thumbnailator - Gerar Thumbnail -->
208+
<dependency>
209+
<groupId>net.coobird</groupId>
210+
<artifactId>thumbnailator</artifactId>
211+
<version>${thumbnailator.version}</version>
212+
<scope>compile</scope>
213+
</dependency>
214+
215+
<!-- Thymeleaf extras data attribute -->
216+
<dependency>
217+
<groupId>com.github.mxab.thymeleaf.extras</groupId>
218+
<artifactId>thymeleaf-extras-data-attribute</artifactId>
219+
<version>${thymeleaf-extras-data-attribute.version}</version>
220+
<scope>compile</scope>
221+
</dependency>
222+
223+
</dependencies>
224+
225+
</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)