Skip to content

Commit 2115614

Browse files
committed
Adicionado aula 22.14 com código-fonte atualizado para Spring Boot 2.7.0
1 parent 69085a1 commit 2115614

File tree

59 files changed

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

59 files changed

+3264
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
/*
2+
* Copyright 2007-present the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
import java.net.*;
17+
import java.io.*;
18+
import java.nio.channels.*;
19+
import java.util.Properties;
20+
21+
public class MavenWrapperDownloader {
22+
23+
private static final String WRAPPER_VERSION = "0.5.6";
24+
/**
25+
* Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided.
26+
*/
27+
private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/"
28+
+ WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar";
29+
30+
/**
31+
* Path to the maven-wrapper.properties file, which might contain a downloadUrl property to
32+
* use instead of the default one.
33+
*/
34+
private static final String MAVEN_WRAPPER_PROPERTIES_PATH =
35+
".mvn/wrapper/maven-wrapper.properties";
36+
37+
/**
38+
* Path where the maven-wrapper.jar will be saved to.
39+
*/
40+
private static final String MAVEN_WRAPPER_JAR_PATH =
41+
".mvn/wrapper/maven-wrapper.jar";
42+
43+
/**
44+
* Name of the property which should be used to override the default download url for the wrapper.
45+
*/
46+
private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl";
47+
48+
public static void main(String args[]) {
49+
System.out.println("- Downloader started");
50+
File baseDirectory = new File(args[0]);
51+
System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath());
52+
53+
// If the maven-wrapper.properties exists, read it and check if it contains a custom
54+
// wrapperUrl parameter.
55+
File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH);
56+
String url = DEFAULT_DOWNLOAD_URL;
57+
if(mavenWrapperPropertyFile.exists()) {
58+
FileInputStream mavenWrapperPropertyFileInputStream = null;
59+
try {
60+
mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile);
61+
Properties mavenWrapperProperties = new Properties();
62+
mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream);
63+
url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url);
64+
} catch (IOException e) {
65+
System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'");
66+
} finally {
67+
try {
68+
if(mavenWrapperPropertyFileInputStream != null) {
69+
mavenWrapperPropertyFileInputStream.close();
70+
}
71+
} catch (IOException e) {
72+
// Ignore ...
73+
}
74+
}
75+
}
76+
System.out.println("- Downloading from: " + url);
77+
78+
File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH);
79+
if(!outputFile.getParentFile().exists()) {
80+
if(!outputFile.getParentFile().mkdirs()) {
81+
System.out.println(
82+
"- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'");
83+
}
84+
}
85+
System.out.println("- Downloading to: " + outputFile.getAbsolutePath());
86+
try {
87+
downloadFileFromURL(url, outputFile);
88+
System.out.println("Done");
89+
System.exit(0);
90+
} catch (Throwable e) {
91+
System.out.println("- Error downloading");
92+
e.printStackTrace();
93+
System.exit(1);
94+
}
95+
}
96+
97+
private static void downloadFileFromURL(String urlString, File destination) throws Exception {
98+
if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) {
99+
String username = System.getenv("MVNW_USERNAME");
100+
char[] password = System.getenv("MVNW_PASSWORD").toCharArray();
101+
Authenticator.setDefault(new Authenticator() {
102+
@Override
103+
protected PasswordAuthentication getPasswordAuthentication() {
104+
return new PasswordAuthentication(username, password);
105+
}
106+
});
107+
}
108+
URL website = new URL(urlString);
109+
ReadableByteChannel rbc;
110+
rbc = Channels.newChannel(website.openStream());
111+
FileOutputStream fos = new FileOutputStream(destination);
112+
fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
113+
fos.close();
114+
rbc.close();
115+
}
116+
117+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.1/apache-maven-3.8.1-bin.zip
2+
wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
web: java -Dserver.port=$PORT -Dspring.profiles.active=prod $JAVA_OPTS -jar target/algamoney*.jar
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!-- Created with Jaspersoft Studio version 6.5.1.final using JasperReports Library version 6.5.1 -->
3+
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="lancamentos-por-pessoa" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="58acf290-79bc-4138-8b10-a72f7a0d1323">
4+
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="One Empty Record"/>
5+
<parameter name="DT_INICIO" class="java.util.Date"/>
6+
<parameter name="DT_FIM" class="java.util.Date"/>
7+
<queryString>
8+
<![CDATA[]]>
9+
</queryString>
10+
<field name="total" class="java.math.BigDecimal"/>
11+
<field name="tipo" class="com.example.algamoney.api.model.TipoLancamento"/>
12+
<field name="pessoa" class="com.example.algamoney.api.model.Pessoa"/>
13+
<title>
14+
<band height="60" splitType="Stretch">
15+
<textField>
16+
<reportElement x="11" y="15" width="533" height="30" uuid="4c0dc64f-1b05-4145-a713-4d57089e6f8b"/>
17+
<textElement textAlignment="Center" verticalAlignment="Middle">
18+
<font size="18"/>
19+
</textElement>
20+
<textFieldExpression><![CDATA["Lançamentos por pessoa de " + DATEFORMAT($P{DT_INICIO}, "dd/MM/yyyy") + " até " + DATEFORMAT($P{DT_FIM}, "dd/MM/yyyy")]]></textFieldExpression>
21+
</textField>
22+
</band>
23+
</title>
24+
<columnHeader>
25+
<band height="25" splitType="Stretch">
26+
<rectangle>
27+
<reportElement x="0" y="0" width="555" height="25" backcolor="#D4D4D4" uuid="6286af83-11eb-4a4f-811c-7f1ff4d3dc46"/>
28+
</rectangle>
29+
<line>
30+
<reportElement x="80" y="0" width="1" height="25" uuid="57a07db4-d370-440d-889c-2d451fae5c70"/>
31+
</line>
32+
<line>
33+
<reportElement x="480" y="0" width="1" height="25" uuid="a3a84aff-06b3-4e87-b66d-ced0367ec30d"/>
34+
</line>
35+
<staticText>
36+
<reportElement x="1" y="1" width="79" height="23" uuid="4e3327e0-a0b5-4bf4-96f0-0be06a48d412"/>
37+
<textElement textAlignment="Center" verticalAlignment="Middle"/>
38+
<text><![CDATA[Tipo]]></text>
39+
</staticText>
40+
<staticText>
41+
<reportElement x="82" y="1" width="398" height="23" uuid="2731a6ea-556b-47e6-95ff-909ee28bad4c"/>
42+
<textElement textAlignment="Center" verticalAlignment="Middle"/>
43+
<text><![CDATA[Pessoa]]></text>
44+
</staticText>
45+
<staticText>
46+
<reportElement x="481" y="1" width="74" height="23" uuid="28c8e6f1-c298-4f95-bc28-f0c9aa315282"/>
47+
<textElement textAlignment="Center" verticalAlignment="Middle"/>
48+
<text><![CDATA[Total]]></text>
49+
</staticText>
50+
</band>
51+
</columnHeader>
52+
<detail>
53+
<band height="25" splitType="Stretch">
54+
<line>
55+
<reportElement x="0" y="0" width="1" height="25" uuid="97b64cbd-bf37-42ab-b44f-598d19309f0c"/>
56+
</line>
57+
<line>
58+
<reportElement x="80" y="0" width="1" height="25" uuid="ad4cdbf3-6af5-44c2-9260-74a0f5417bdd"/>
59+
</line>
60+
<line>
61+
<reportElement x="480" y="0" width="1" height="25" uuid="910afb37-4d92-4274-a384-29664034be43"/>
62+
</line>
63+
<line>
64+
<reportElement x="554" y="0" width="1" height="25" uuid="0425291a-62a8-41aa-81de-ccbafca0c581"/>
65+
</line>
66+
<line>
67+
<reportElement x="0" y="24" width="555" height="1" uuid="50d4b333-1e55-411f-8ea1-b9e4e5eeb527"/>
68+
</line>
69+
<textField>
70+
<reportElement x="5" y="1" width="69" height="23" uuid="2bd81544-88ba-49f7-a9d9-37c6b99bf4e7"/>
71+
<textElement verticalAlignment="Middle"/>
72+
<textFieldExpression><![CDATA[$F{tipo}.getDescricao()]]></textFieldExpression>
73+
</textField>
74+
<textField>
75+
<reportElement x="90" y="1" width="379" height="22" uuid="dbe6c9a0-8a52-4702-b728-f98b47da0ea5"/>
76+
<textElement verticalAlignment="Middle"/>
77+
<textFieldExpression><![CDATA[$F{pessoa}.getNome()]]></textFieldExpression>
78+
</textField>
79+
<textField pattern="¤#,##0.00;¤-#,##0.00">
80+
<reportElement x="495" y="1" width="54" height="24" uuid="89c71af5-f01d-422a-821d-e3b203ef9191"/>
81+
<textElement textAlignment="Right" verticalAlignment="Middle"/>
82+
<textFieldExpression><![CDATA[$F{total}]]></textFieldExpression>
83+
</textField>
84+
</band>
85+
</detail>
86+
<pageFooter>
87+
<band height="25" splitType="Stretch">
88+
<textField>
89+
<reportElement x="1" y="0" width="140" height="25" uuid="51868060-3978-478a-be3c-c7f2b21939fb"/>
90+
<textElement verticalAlignment="Middle"/>
91+
<textFieldExpression><![CDATA["Data " + DATEFORMAT(TODAY(), "dd/MM/yyyy")]]></textFieldExpression>
92+
</textField>
93+
<textField>
94+
<reportElement x="454" y="0" width="100" height="25" uuid="ab1c2327-7749-4f1c-9322-86b1698276ca"/>
95+
<textElement textAlignment="Right" verticalAlignment="Middle"/>
96+
<textFieldExpression><![CDATA[$V{PAGE_NUMBER}]]></textFieldExpression>
97+
</textField>
98+
</band>
99+
</pageFooter>
100+
</jasperReport>

0 commit comments

Comments
 (0)