Adding Spring Framework Support in IntelliJ - no such option - java

So, I've got a simple Maven Project and I want to add Spring Framework Support, mainly to generate Spring Config file. However, in the IntelliJ menu called Add Framework Support, I see no Spring option
This is my pom.xml file:
<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>pl.javastart</groupId>
<artifactId>spring-di-xml</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<maven.compiler.source>12</maven.compiler.source>
<maven.compiler.target>12</maven.compiler.target>
<spring-framework.version>5.0.6.RELEASE</spring-framework.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${spring-framework.version}</version>
</dependency>
</dependencies>
</project>
I've tried reimporting Maven with no results.
Any suggestions will be much appreciated.
NOTE: IT'S THE ULTIMATE EDITION 2019.2.3
EDIT:
Spring plugins are active.
Facests:

Spring framework support is available only in Ultimate Edition of IDEA.
This feature is only supported in the Ultimate edition.
See: https://www.jetbrains.com/help/idea/spring-support.html
Edit:
Go to Plugins and on the left you see Bundled header. Check if Spring tools are deactivated there.

Related

IntelliJ can't find google-cloud-storage classes

I'm trying to use Google cloud storage and I'm following this guide: https://cloud.google.com/storage/docs/reference/libraries#using_the_client_library
I'm using Java with Maven, and this is my Pom.xml:
<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.findwise.app</groupId>
<artifactId>data-pipeline</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-pubsub</artifactId>
<version>0.32.0-beta</version>
</dependency>
<dependency>
<groupId>com.google.cloud.dataflow</groupId>
<artifactId>google-cloud-dataflow-java-sdk-all</artifactId>
<version>2.2.0</version>
</dependency>
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-storage</artifactId>
<version>1.70.0</version>
</dependency>
</dependencies>
</project>
As you can see I've added the google-cloud-storage dependency. My problem is that the classes used in the Java part of the guide (Storage, StorageOptions, Bucket, BucketInfo) are unfindable by IntelliJ. I can't import them. In fact, when I try to import via the absolute path:
import com.google.cloud.storage.Storage;
IntelliJ complains that the symbol google cannot be resolved. What is wrong here?
There are a few places to look:
Find your local .m2 repository and navigate to the com.google.cloud dependencies. If you don't find it, or the JARs aren't there, IntelliJ won't be able to access them.
IntelliJ will show you the External Libraries it is using under your source code in the project panel on the left.
If IntelliJ cannot import the class, it suggests that your Maven pull isn't working.

Spring Boot maven spring-could-starter-parent Brixton.RELEASE changes hibernate-core dependency

I have a project that depends on hibernate-core 3.6.4.Final, lets call it "MyDatabaseProject".
I have a second project which is a spring-cloud project, it depends on MyDatabaseProject.
The spring cloud project uses spring-cloud-starter-parent Brixton.RELEASE as it's parent pom.
When I check the dependencies (using "mvn dependency:list") I see that I now have a dependency on hibernate-core:4.3.11.Final, not 3.6.4.Final.
If I switch the spring-cloud-starter-parent version back to Angel.SR6, and I check the dependencies (using "mvn dependency:list") I see that I have a dependency on hibernate-core:3.6.4.Final, as I would expect.
It appears to me that something changed in the Brixton.RELEASE that overrides the hibernate-core version.
My question is, is this a bug, or unintentional change in the Brixton.RELEASE?
If it is intentional, what it the correct way to deal with this?
I have tried adding a dependencyManagement section to the spring cloud project pom with the hibernate-core:3.6.4.Final, and that did work, but I don't know if that is the correct way to deal with the problem. It doesn't seem right for the top level project to care about what hibernate version the lower level project uses.
Here are the minimal maven poms for the spring cloud project and the database project:
<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>example</groupId>
<artifactId>MySpringCloudProject</artifactId>
<version>1.0.0</version>
<parent>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-parent</artifactId>
<version>Brixton.RELEASE</version>
<!-- <version>Angel.SR6</version> -->
</parent>
<dependencies>
<dependency>
<groupId>example</groupId>
<artifactId>MyDatabaseProject</artifactId>
<version>1.0.0</version>
</dependency>
</dependencies>
</project>
And the database project:
<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>example</groupId>
<artifactId>MyDatabaseProject</artifactId>
<version>1.0.0</version>
<dependencies>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>3.6.4.Final</version>
</dependency>
</dependencies>
</project>

How can I import Spring Framework into Eclipse?

I am having trouble importing spring framework into eclipse. I have downloaded spring but am unable to import it. Can anyone help or direct me to a web page that can do so?
You can either follow this tutorial:
http://www.tutorialspoint.com/spring/spring_hello_world_example.htm
or use the spring eclipse plugin (you can find it in eclipse under Help/eclipse marketplace and search for it)
or you can use a tool to manage your dependencies like maven.
It wouldn't be a bad idea to get familiar with a dependency manager like Maven. For use in Eclipse there is a nice plugin M2Eclipse. The pom.xml file is what you use to specify your dependencies, and then when you build with Maven it resolves everything for you and downloads automatically anything it needs. This is the example pom.xml file from the Maven installation instructions:
<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.mycompany.app</groupId>
<artifactId>my-app</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>Maven Quick Start Archetype</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.2</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
The dependency for the core Spring Framework is
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>4.1.6.RELEASE</version>
</dependency>
And generally you can find the pom.xml dependency specifications at the Maven Repository. Might seem a little overdone for simply getting Spring into Eclipse, but once you have it set up it is then a snap to add more dependencies down the road, all you do is add the appropriate item to the pom.xml file.

Maven not pulling down correct JClouds-Chef dependency tree

I'm trying to figure out how to use the JClouds-Chef library to configure VMs. According to their Installation Guide I can just create a pom.xml that looks like:
<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<properties>
<jclouds.version>1.7.3</jclouds.version>
</properties>
<groupId>com.mycompany.app</groupId>
<artifactId>my-app</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>org.apache.jclouds</groupId>
<artifactId>jclouds-all</artifactId>
<version>${jclouds.version}</version>
</dependency>
</dependencies>
</project>
And run mvn dependency:copy-dependencies and it should pull down all the JARs that JClouds-Chef requires.
So I did this, and then added all the JARs (there were a lot) to my project's buildpath. I then tried to create ChefContext instance (like their tutorials show examples of):
ChefContext context = null;
And Eclipse can't resolve/find the ChefContext class. After scanning the JARs that Maven downloaded, sure enough, ChefContext doesn't appear anywhere!
So I ask: **what are the exact steps I need to get all the JARs that comprise JClouds-Chef and all of its dependencies?*
You must explicitly add chef to your dependencies stanza:
<dependency>
<groupId>org.apache.jclouds.api</groupId>
<artifactId>chef</artifactId>
<version>${jclouds.version}</version>
</dependency>
You can consult chef-basics in jclouds-examples for a working example.
Adding that dependency should be enough. Alternatively, if you want to use Enterprise Chef specific features, you can add the following one instead:
<dependency>
<groupId>org.apache.jclouds.provider</groupId>
<artifactId>enterprisechef</artifactId>
<version>${jclouds.version}</version>
</dependency>
That's the only thing you need to configure. jclouds will take care of installing Chef and all the required dependencies in the nodes you provision.

Multiple maven pom.xml files

I have an Eclipse project with a GWT client and a Restlet API. I normally use Maven for dependency management but I havent used it in an Eclipse project where seperate parts have seperate dependencies. For example - the client would use Google Gin for dependency injection and the server uses Google Guice.
Am I able to split it into two seperate pom.xml files to manage the dependencies of both seperate areas?
Thanks
You can create a multi module project. See examples here and here and here.
You could create a new pom like this:
<?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
http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.mycompany</groupId>
<artifactId>your-dependencies</artifactId>
<version>1.0.0</version>
<packaging>pom</packaging>
<dependencies>
...
<dependency>
<groupId>com.sun.mail</groupId>
<artifactId>mailapi</artifactId>
<version>1.5.0</version>
</dependency>
...
</dependencies>
</project>
Then in your original project just add:
<dependencies>
<dependency>
<groupId>com.mycompany</groupId>
<artifactId>your-dependencies</artifactId>
<version>1.0.0</version>
<type>pom</type>
</dependency>
</dependencies>

Categories