how to set java class loader PARENT_LAST

If you are only deploying the WAR file itself you can’t control this, but if you have your WAR file in an EAR file you can use the deployment.xml solution. The deployment.xml file would look something like this: <?xml version=”1.0″ encoding=”UTF-8″?> <appdeployment:Deployment xmi:version=”2.0″ xmlns:xmi=”http://www.omg.org/XMI” xmlns:appdeployment=”http://www.ibm.com/websphere/appserver/schemas/5.0/appdeployment.xmi” xmi:id=”Deployment_1347529484613″> <deployedObject xmi:type=”appdeployment:ApplicationDeployment” xmi:id=”ApplicationDeployment_1347544766353″ startingWeight=”99″ warClassLoaderPolicy=”SINGLE”> <modules xmi:type=”appdeployment:WebModuleDeployment” xmi:id=”WebModuleDeployment_1347543866613″ startingWeight=”1″ … Read more

ClassNotFoundException with com.mysql.cj.jdbc.Driver, MySQL Connector and IntelliJ IDEA [duplicate]

Try upgrading your driver. Coz Mysql community has updated class name from com.mysql.jdbc.Driver to com.mysql.cj.jdbc.Driver Check out more on MySql Community <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>8.0.11</version> Or Download jar file direct from here : mysql-connector-java-8.0.11.jar List of MySql jar file

Maven build issue – Connection to repository refused

Most probably you are behind proxy. Try to do a telnet repo.maven.apache.org 80 and probably you will find it failed to connect. In your settings.xml, add corresponding proxy settings to tell Maven to go through the proxy to download the artifacts <settings> ……. <proxies> <proxy> <active>true</active> <protocol>http</protocol> <host>your_proxy_host</host> <port>your_proxy_port</port> <!– <username>proxyuser</username> <password>somepassword</password> <nonProxyHosts>*.yourdomain.com|*.yourOtherDomain.com</nonProxyHosts> –> </proxy> … Read more

How to configure maven to use different log4j.properties files in different environments

You can use profiles to achieve the desired behavior: <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-resources-plugin</artifactId> <version>2.5</version> <executions> <execution> <id>log4j</id> <phase>process-resources</phase> <goals> <goal>copy-resources</goal> </goals> <configuration> <outputDirectory>output_directory</outputDirectory> <resources> <resource>${log4j.file}</resource> </resources> </configuration> </execution> </executions> </plugin> </plugins> </build> <profiles> <profile> <id>dev</id> <activation> <activeByDefault>true</activeByDefault> </activation> <properties> <log4j.file>path_to_file_A</log4j.file> </properties> </profile> <profile> <id>prod</id> <properties> <log4j.file>path_to_file_B</log4j.file> </properties> </profile> </profiles>

Generate test-jar along with jar file in test package

By using the following configuration you can create a jar from your tests: <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jar-plugin</artifactId> <version>2.6</version> <executions> <execution> <goals> <goal>test-jar</goal> </goals> </execution> </executions> </plugin> To use such kind of artifact: <dependencies> <dependency> <groupId>groupId</groupId> <artifactId>artifactId</artifactId> <type>test-jar</type> <version>version</version> <classifier>tests</classifier> <scope>test</scope> </dependency> </dependencies>