Connect timeout while connecting to mongodb docker container running on VirtualBox (Windows 7) - mongodb

Trying to connect to mongodb docker container running on VirtualBox (as I have a windows setup). I'm making the connection using spring-boot project running on intellij on my Local Windows Machine.
Is there a configuration file in spring-boot I could use to specify host and port before attempting the connection to mongodb?
I already tried modifying application.properties (added ip for the VM that docker threw up initially - see docker console image) but it didn't work.
enter image description here
enter image description here
pom.xml entry:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.0.M7</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-mongodb</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>spring-snapshots</id>
<name>Spring Snapshots</name>
<url>https://repo.spring.io/snapshot</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
<repository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>https://repo.spring.io/milestone</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>spring-snapshots</id>
<name>Spring Snapshots</name>
<url>https://repo.spring.io/snapshot</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
<pluginRepository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>https://repo.spring.io/milestone</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
Help appreciated.

Related

Content assist not working for joinfaces component in eclipse

Content assist and new xhtml page option is not working for joinfaces.
I am following the example project present in Example.
I have tried multiple solution nothing seems to be working.
Not able to create new xhtml page neither getting content assist for bean classes.
Eclipse IDE for java developers 2020-06.
<h:outputText value="#{test.helloWorld.firstName}" />
After # nothing is showing but after h it is showing the options.
#Component
#ViewScoped
public class Test {
#Getter
#Setter
public HelloWorld helloWorld;
#PostConstruct
public void init() {
helloWorld = new HelloWorld();
}
public String changePage() {
return "success";
}
public void save() {
System.out.println("Hello"+helloWorld.getFirstName()+helloWorld.getLastName());
}
}
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.5.0-M2</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<groupId>com.ap</groupId>
<artifactId>test</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>test</name>
<description>Test</description>
<properties>
<java.version>8</java.version>
<joinfaces.version>4.5.0-m2</joinfaces.version>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.joinfaces</groupId>
<artifactId>joinfaces-dependencies</artifactId>
<version>${joinfaces.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.joinfaces</groupId>
<artifactId>security-spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.joinfaces</groupId>
<artifactId>primefaces-spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.joinfaces</groupId>
<artifactId>richfaces-spring-boot-starter</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<excludes>
<exclude>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>https://repo.spring.io/milestone</url>
</repository>
<repository>
<id>spring-snapshots</id>
<name>Spring Snapshots</name>
<url>https://repo.spring.io/snapshot</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>https://repo.spring.io/milestone</url>
</pluginRepository>
<pluginRepository>
<id>spring-snapshots</id>
<name>Spring Snapshots</name>
<url>https://repo.spring.io/snapshot</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
</project>

Spring boot data jpa APPLICATION FAILED TO START

I learn JPA from https://spring.io/guides/gs/accessing-data-jpa/#initial and git clone project
I did a java file following this example but it is still error.
How can I fix it?
-----------
-----------
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2018-06-09 16:41:37.706 ERROR 18872 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter :
APPLICATION FAILED TO START
Description:
Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.
Reason: Failed to determine a suitable driver class
Action:
Consider the following:
If you want an embedded database (H2, HSQL or Derby), please put it on the classpath.
If you have database settings to be loaded from a particular profile you may need to activate it (no profiles are currently active).
---------
---------
pom.xml file
http://maven.apache.org/maven-v4_0_0.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
4.0.0
<groupId>org.springframework</groupId>
<artifactId>gs-accessing-data-jpa</artifactId>
<version>0.1.0</version>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.2.RELEASE</version>
</parent>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>spring-releases</id>
<name>Spring Releases</name>
<url>https://repo.spring.io/libs-release</url>
</repository>
<repository>
<id>org.jboss.repository.releases</id>
<name>JBoss Maven Release Repository</name>
<url>https://repository.jboss.org/nexus/content/repositories/releases</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>spring-releases</id>
<name>Spring Releases</name>
<url>https://repo.spring.io/libs-release</url>
</pluginRepository>
</pluginRepositories>
You used spring-boot-starter-data-jpa in your pom.xml. But I guess, no data source adjusted in appllication.properties file. If you wanna use DB connections, application.properties file should contain configurations like this:
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.username=mysqluser
spring.datasource.password=mysqlpass
spring.datasource.url=jdbc:mysql://localhost:8080/myDb?createDatabaseIfNotExist=true
Otherwise if you don't use jpa, remove spring-boot-starter-data-jpa dependency from pom.xml:
remove:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
And then try again to run the application.

Maven can't find artifact for Spring Boot 2.0.0.M2 in Spring Repo

Discovered that to use Spring Data ElasticSearch with ElasticSearch 5.5.0 that you need to use Spring Boot's 2.0.0.M2 milestone... However, something is wrong with my pom where maven can't seem to find the Spring Boot 2.0.0.M2 milestone from the Maven repositories that I specified.
pom.xml:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.0.M2</version>
</parent>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<!-- Elasticsearch -->
<dependency>
<groupId>org.elasticsearch</groupId>
<artifactId>elasticsearch</artifactId>
<version>5.5.0</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot</artifactId>
<version>2.0.0.M2</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-elasticsearch</artifactId>
<version>2.0.0.M2</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<!-- Package as an executable jar/war -->
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>spring-libs-snapshot</id>
<name>Spring Snapshot Repository</name>
<url>http://repo.spring.io/libs-snapshot</url>
</repository>
<repository>
<id>spring-releases</id>
<url>https://repo.spring.io/libs-release</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>spring-releases</id>
<url>https://repo.spring.io/libs-release</url>
</pluginRepository>
</pluginRepositories>
Received the following problem when doing a Maven -> Update Project in Eclipse:
Maven pom Loading Problem: Could not find artifact org.springframework.boot:spring-boot-maven-plugin:jar:2.0.0.M2 in spring-releases (https://repo.spring.io/libs-release) pom.xml
For milestone versions you have to add the milestone repository with the URL https://repo.spring.io/libs-milestone/.

Maven dependency error (artifact)

I'm trying to install Fenix framework with maven adding the following dependence:
<dependency>
<groupId>pt.ist</groupId>
<artifactId>fenix-framework-backend-infinispan</artifactId>
<version>2.0-cloudtm</version>
</dependency>
gives the following error: missing artifact ...
My POM.xml :
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.isban.test</groupId>
<artifactId>fenixtest</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>fenixtest</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>pt.ist</groupId>
<artifactId>fenix-framework-backend-infinispan</artifactId>
<version>2.0-cloudtm</version>
</dependency>
</dependencies>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
<pluginRepositories>
<pluginRepository>
<id>fenix-ashes-maven-repository</id>
<url>https://fenix-ashes.ist.utl.pt/maven-public</url>
</pluginRepository>
</pluginRepositories>
<repositories>
<repository>
<id>fenix-ashes-maven-repository</id>
<url>https://fenix-ashes.ist.utl.pt/maven-public</url>
</repository>
</repositories>
</project>
Official documentation : https://fenix-framework.github.io/Usage.html
Does anyone know what I'm doing wrong?
Those artifacts are not available on Maven Central but on a specific Fénix repository. From the official page:
These artifacts are available via the Fénix Framework Nexus repository, so you need to add it to your configuration:
<pluginRepositories>
<pluginRepository>
<id>fenix-ashes-maven-repository</id>
<url>https://fenix-ashes.ist.utl.pt/maven-public</url>
</pluginRepository>
</pluginRepositories>
<repositories>
<repository>
<id>fenix-ashes-maven-repository</id>
<url>https://fenix-ashes.ist.utl.pt/maven-public</url>
</repository>
</repositories>
There is actually a typo in that page, that I corrected here: the last element should be <repositories> and not <pluginRepositories>. Therefore, you need to add those repositories to your POM (or to your Maven settings).
The dependency
<dependency>
<groupId>pt.ist</groupId>
<artifactId>fenix-framework-backend-infinispan</artifactId>
<version>2.0-cloudtm</version>
</dependency>
is also incorrect from the documentation: that artifact indeed doesn't exist. The latest version is 2.6.2 and the artifact should be fenix-framework-backend-infinispan-code-generator, so you should have instead:
<dependency>
<groupId>pt.ist</groupId>
<artifactId>fenix-framework-backend-infinispan-code-generator</artifactId>
<version>2.6.2</version>
</dependency>

Unable to execute Spray Examples | Maven dependency error

I am just trying to have hands on Spray library however am not able to execute its examples due to maven dependency.
As provided in docs I have defined Spray repository as follows:
<repositories>
<repository>
<id>sprayrepo</id>
<name>spray repo</name>
<url>http://repo.spray.io/</url>
<layout>default</layout>
</repository>
</repositories>
Then I have defined its dependency as follows:
<dependency>
<groupId>io.spray</groupId>
<artifactId>spray-http</artifactId>
<version>1.1-M7</version>
</dependency>
<dependency>
<groupId>io.spray</groupId>
<artifactId>spray-httpx</artifactId>
<version>1.1-M7</version>
</dependency>
<dependency>
<groupId>io.spray</groupId>
<artifactId>spray-util</artifactId>
<version>1.1-M7</version>
</dependency>
<dependency>
<groupId>com.chuusai</groupId>
<artifactId>shapeless_2.9.2</artifactId>
<version>1.2.0</version>
</dependency>
</dependencies>
However when I try to execute to maven install, I face following error:
[ERROR] Failed to execute goal on project spray-test1: Could not
resolve dependencies for project
org.spray:spray-test1:jar:1.0-SNAPSHOT: Failed to collect dependencies
for [io.spray:spray-http:jar:1.1-M7 (compile),
io.spray:spray-httpx:jar:1.1-M7 (compile),
io.spray:spray-util:jar:1.1-M7 (compile),
com.chuusai:shapeless_2.9.2:jar:1.2.0 (compile)]: Failed to read
artifact descriptor for io.spray:spray-http:jar:1.1-M7: Could not
transfer artifact io.spray:spray-http:pom:1.1-M7 from/to sprayrepo
(http://repo.spray.io/): connection timed out to
http://repo.spray.io/io/spray/spray-http/1.1-M7/spray-http-1.1-M7.pom
-> [Help 1] [ERROR]
Any Pointers or suggestions will be highly appreciated.
Thanks
Try this:
<properties>
<maven.compiler.source>1.6</maven.compiler.source>
<maven.compiler.target>1.6</maven.compiler.target>
<encoding>UTF-8</encoding>
<scala.tools.version>2.10</scala.tools.version>
<scala.version>2.10.2</scala.version>
</properties>
<dependencies>
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-library</artifactId>
<version>${scala.version}</version>
</dependency>
<dependency>
<groupId>io.spray</groupId>
<artifactId>spray-can</artifactId>
<version>1.1-M8</version>
</dependency>
<!-- Test -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.specs2</groupId>
<artifactId>specs2_${scala.tools.version}</artifactId>
<version>1.13</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.scalatest</groupId>
<artifactId>scalatest_${scala.tools.version}</artifactId>
<version>2.0.M6-SNAP8</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<sourceDirectory>src/main/scala</sourceDirectory>
<testSourceDirectory>src/test/scala</testSourceDirectory>
<plugins>
<plugin>
<!-- see http://davidb.github.com/scala-maven-plugin -->
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
<version>3.1.3</version>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>testCompile</goal>
</goals>
<configuration>
<args>
<arg>-make:transitive</arg>
<arg>-dependencyfile</arg>
<arg>${project.build.directory}/.scala_dependencies</arg>
</args>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.13</version>
<configuration>
<useFile>false</useFile>
<disableXmlReport>true</disableXmlReport>
<!-- If you have classpath issue like NoDefClassError,... -->
<!-- useManifestOnlyJar>false</useManifestOnlyJar -->
<includes>
<include>**/*Test.*</include>
<include>**/*Suite.*</include>
</includes>
</configuration>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>SonatypeNexusSnapshots</id>
<name>Sonatype Nexus Snapshots</name>
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
</repository>
<repository>
<id>FuseSourceSnapshotRepository</id>
<name>FuseSource Snapshot Repository</name>
<url>http://repo.fusesource.com/nexus/content/repositories/snapshots/</url>
</repository>
<repository>
<id>ScalaToolsMaven2Repository</id>
<name>Scala-Tools Maven2 Repository</name>
<url>http://scala-tools.org/repo-releases/</url>
</repository>
<repository>
<id>scala-tools.org</id>
<name>Scala-Tools Maven2 Repository</name>
<url>http://scala-tools.org/repo-releases</url>
</repository>
<repository>
<id>sprayrepo</id>
<name>spray repo</name>
<url>http://repo.spray.io/</url>
<layout>default</layout>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>scala-tools.org</id>
<name>Scala-Tools Maven2 Repository</name>
<url>http://scala-tools.org/repo-releases</url>
</pluginRepository>
</pluginRepositories>