Skip to content

Commit 1435858

Browse files
committed
Projeto do curso
1 parent 0e2e7c2 commit 1435858

File tree

150 files changed

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

150 files changed

+45891
-0
lines changed

Diff for: 18.5-input-e-componente-para-data/brewer/pom.xml

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