Skip to content

Commit 01a2239

Browse files
committed
Projeto do curso
1 parent 42e49e3 commit 01a2239

File tree

1,600 files changed

+695227
-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,600 files changed

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