Maven - studiofu/brain GitHub Wiki

Quick Start

The instructions below are quick-start guides to building sources with Maven. You may refer to the following for details on the Maven command:

https://maven.apache.org/guides/getting-started/maven-in-five-minutes.html

https://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html

Maven Eclipse Web Development

  • need to know spring mvc
  • need to know how to apply the connection pool
  • need to know how to use maven in the eclipse
  • setup in command prompt
  • add mssql jar to the self repo
  • need to know how to setup JNDI resources in the servers

Local Development Environment Setup

  • Prepare Eclipse for Maven
    • Install springsource-tool-suite to Eclipse, or
    • Download the all-in-one internal installation or get it from another colleague.
  • (Optional but recommended) Install Maven to your machine.

Maven's Central Repository

https://repo.maven.apache.org/maven2

Internal repository

Includes artifacts not available in the Central Maven Repository:

CrystalReports Java runtime libraries

https://archive.sap.com/documents/docs/DOC-29757

Oracle JDBC driver

http://www.oracle.com/technetwork/apps-tech/jdbc-112010-090769.html

MS SQL Server JDBC driver (Type 4)

https://docs.microsoft.com/en-us/sql/connect/jdbc/microsoft-jdbc-driver-for-sql-server?view=sql-server-2017

Download site for v4.2: https://www.microsoft.com/en-us/download/details.aspx?id=54671

JT400 - IBM Toolbox for Java, which includes the JDBC driver to access CAPSIL data

https://www-03.ibm.com/systems/power/software/i/toolbox/

Build from Command Line

mvn clean package

Skip Test

-Dmaven.test.skip=true

Maven Repo Download Problem

download the cert ⇒:gn16:jssecacerts.zip

then extract and put the file to the $JAVA_HOME/jre/lib/security/ (NOTE: must use JDK and not JRE)

it could resolve the connection and ssl problem between the central repo and local development machine which is behind websense (https://repo.maven.apache.org/maven2)

the cert is generated by the java program ⇒ :gn16:installcert.zip

https://github.com/escline/InstallCert/blob/master/InstallCert.java

/cygdrive/c/temp $ java InstallCert
Usage: java InstallCert <host>[:port] [passphrase]

https://superuser.com/questions/33588/how-to-view-internet-explorer-auto-detected-proxy-settings

https://web.liferay.com/web/neil.griffin/blog/-/blogs/fixing-suncertpathbuilderexception-caused-by-maven-downloading-from-self-signed-repository

download the ssl cert from https://repo.maven.apache.org/maven2/

add to the eclipse ssl cert (preference → search ssl)

https://stackoverflow.com/questions/19537396/missing-artifact-com-microsoft-sqlserversqljdbc4jar4-0

add sqljdbc42 to the self repo if the connection to mssql database is required

mvn install:install-file -Dfile=sqljdbc42.jar -DgroupId=com.microsoft.sqlserver -DartifactId=sqljdbc4 -Dversion=4.2 -Dpackaging=jar

Maven Related Issue, i.e. cannot compile, error and etc... need to clean maven or remove local .m2

https://stackoverflow.com/questions/15506043/create-a-maven-project-in-eclipse-complains-could-not-resolve-archetype

https://stackoverflow.com/questions/19871437/the-import-org-springframework-cannot-be-resolved

"Missing artifact" error for dependency JARs that do exist

https://stackoverflow.com/questions/6111408/maven2-missing-artifact-but-jars-are-in-place

https://stackoverflow.com/questions/14807869/eclipse-does-not-recognize-existing-resolved-maven-dependencies

Using Jetty

need to apply and use the maven jetty plugin

      <!-- jetty-maven-plugin -->
      <plugin>
        <groupId>org.eclipse.jetty</groupId>
        <artifactId>jetty-maven-plugin</artifactId>
        <version>${jetty-maven-plugin.version}</version>
        <configuration>
          <scanIntervalSeconds>5</scanIntervalSeconds>
          <httpConnector>
            <port>9090</port>
          </httpConnector>
          <webApp>
            <contextPath>/codenotfound</contextPath>
          </webApp>
        </configuration>
      </plugin>

download and using jetty-runner

      <!-- jetty-runner -->
      <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-dependency-plugin</artifactId>
          <version>2.3</version>
          <executions>
            <execution>
              <phase>package</phase>
              <goals><goal>copy</goal></goals>
              <configuration>
                <artifactItems>
                  <artifactItem>
                    <groupId>org.eclipse.jetty</groupId>
                    <artifactId>jetty-runner</artifactId>
                    <version>9.3.3.v20150827</version>
                    <destFileName>jetty-runner.jar</destFileName>
                  </artifactItem>
                </artifactItems>
              </configuration>
            </execution>
          </executions>
        </plugin>

java -jar target/dependency/jetty-runner.jar target/*.war

apache-jetty connection

https://wiki.eclipse.org/Jetty/Tutorial/Apache#Configuring_mod_proxy_http

Reference Links

Web Development Tutorial

http://www.programcreek.com/2014/02/spring-mvc-helloworld-using-maven-in-eclipse/

https://crunchify.com/how-to-create-dynamic-web-project-using-maven-in-eclipse/

http://www.javahotchocolate.com/tutorials/maven.html

https://www.mkyong.com/maven/how-to-create-a-web-application-project-with-maven/

http://www.javawebtutor.com/articles/maven/maven_index.php

http://viralpatel.net/blogs/spring-4-mvc-tutorial-maven-example/

https://stackoverflow.com/questions/18745770/spring-injection-into-servlet

apply spring bean to servlet

https://stackoverflow.com/questions/14570477/how-to-read-properties-file-in-spring-project

extract properties file and inject to the spring bean

https://stackoverflow.com/questions/28414234/where-can-i-find-the-example-applicationcontext-xml-file

spring properties and database connection

http://www.technicalkeeda.com/spring-tutorials/spring-4-jdbctemplate-annotation-example

spring 4 annotation example

https://stackoverflow.com/questions/10604298/spring-component-versus-bean

spring components vs bean

Database Connection

https://examples.javacodegeeks.com/enterprise-java/tomcat/tomcat-connection-pool-configuration-example/

https://stackoverflow.com/questions/41292167/connection-pool-for-tomcat-in-eclipse-for-ms-sql-server

https://stackoverflow.com/questions/42684781/how-to-implement-sql-server-connection-pooling-in-java-jdbc

https://examples.javacodegeeks.com/core-java/apache/commons/dbcp/dbcp-connection-pooling-example/

https://www.mkyong.com/spring/maven-spring-jdbc-example/

http://www.codejava.net/frameworks/spring/spring-mvc-with-jdbctemplate-example

https://stackoverflow.com/questions/7152829/classpathxmlapplicationcontext-cannot-find-the-xml-file

spring bean xml and connection properties files location

從零開始通過 Artifactory 搭建公網的 maven 倉庫

https://www.itread01.com/articles/1498723209.html

How to setup new local artifactory for maven?

https://stackoverflow.com/questions/14657957/how-to-setup-new-local-artifactory-for-maven

如何在不允许联网的环境下使用Maven开发

https://blog.csdn.net/achilles12345/article/details/9263295

⚠️ **GitHub.com Fallback** ⚠️