My code style settings keep getting reset when I create a new project, and I have to re-export from the default ide configurations.
is it possible to make some factory settings for the project (code style for java, general code style, optimize imports on the fly setting) so that when creating a project they are as I specified them in advance and not set everything up again?
File | New Projects Setup | Settings for New Projects...
Related
Every time I create a new JavaFX project in IntelliJ it loads a simple HelloWorld project in it. How can I make it empty instead (without the need to delete those .java files every time)? Also how can I choose to create the project without a building system (as you can see in the picture, I'm always forced to create the project with Maven or Gradle)
When creating the new project, choose "Java" instead of "JavaFX".
A JavaFX application is just a Java application, so if you don't want the additional things which IntelliJ is doing when you choose to create a JavaFX project (e.g. supplying example code and associating with a build system like Maven or Gradle), you can just choose a basic Java application project from the wizard and it won't do those other things.
See the section in openjfx.io documentation titled "JavaFX and IntelliJ IDEA" for other steps you need to take:
Set the project JDK
File -> Project Structure -> Project
Create a JavaFX library in Idea
File -> Project Structure -> Libraries
Point to the lib folder of the JavaFX SDK.
Add VM options for the module path
Run -> Edit Configurations...
--module-path /path/to/javafx-sdk-15.0.1/lib --add-modules javafx.controls,javafx.fxml
For windows use quotes around the path and \ rather than /.
Run the project
Run -> Run...
You might also need to take the actions identified in the accepted answer to:
How to convert a normal java project in intellij into a JavaFx project
But that answer was written a while back and setting the resource copy configuration to include JavaFX fxml and css files might not be needed anymore.
Now, you might think that is annoying amount of things to do, and I might agree with you.
I want to set code style for the project so that all the developers of the project format the code the same way. All of the team uses IntelliJ. When I add my style in the file
/myproject/.idea/codeStyleSettings.xml
the IDE creates the file
/myproject/.idea/codeStyles/codeStyleConfig.xml
with the contents
<component name="ProjectCodeStyleConfiguration">
<state>
<option name="PREFERRED_PROJECT_CODE_STYLE" value="Default" />
</state>
</component>
Will the default settings override my code style settings? Should I use the same component name in my settings file to override the default one?
In addition to those, I see a codeStyle.xml file in the root directory of some well-known java libraries such as https://github.com/qos-ch/slf4j , is it for another IDE or does that also have an impact on formatting in IntelliJ?
By the way, I think generally code style config is confusing if not mess, there is also IDE level global settings and I think/hope it will be applied when there are no rules for a specific option, right?
Intellij IDEA 2017.3 has got new project code style settings format. Now all code style settings are located under <PROJECT_ROOT>/.idea/codeStyles directory with the ultimate intention to support multiple project code styles linked to different scopes. New code style settings format is also cleaner and contains all code style settings properly grouped per language. Some old legacy Java, HTML settings previously stored without any language tag are moved to "JavaCodeStyleSettings", "HTMLCodeStyleSettings" etc. respectively.
The old .idea/codeStyleSettings.xml is imported into two new files: .idea/codeStyles/codeStyleConfig.xml containing a link to preferred project code style and .idea/codeStyles/Project.xml with code style settings for different languages. The latter is optional and created only if there are non-default settings. If .idea directory is under version control, both files can be added to VCS too. The old codeStyleSettings.xml is kept for backwards compatibility.
Original answer (now obsolete):
.idea/codeStyleSettings.xml stores the project specific code style that is for sharing with the project so that all the team members have the same code style applied automatically for this specific project. Check this answer for details.
.idea/codeStyles/codeStyleConfig.xml is used to override the default project code style.
By default it contains <option name="USE_PER_PROJECT_SETTINGS" value="true" /> so that project specific configuration from .idea/codeStyleSettings.xml is used. If you switch your code style settings to use a scheme stored in the IDE instead of the project scheme, this file will store your choice.
IntelliJ IDEA also has support for .editorconfig which will have the priority and override IDE and project scheme by default. Check the documentation for more details.
codeStyle.xml in the project root is for Eclipse IDE and is not used by IntelliJ IDEA. It can be probably used by IntelliJ IDEA as well, if you have Eclipse Code Formatter plug-in installed and configured accordingly.
I am currently writing a program with intellijea IDEA. I cloned my gitlab project. However, when I try to create new class, I don't get to see the option to create new class. Please what I am doing wrong? Or is there a better way to resolve this issue?
you need to define the content type of a directory. This way IntelliJ can provide context aware menu options for you.
First create a directory. E.g. src/main/java (like maven).
You can set this in the module settings:
Tip: If you use maven or another build tool, you can add support for that tool to your project too.
How can I configure IntelliJ IDEA to have Annotation processors enabled by default?
Currently, I have to enable it manually for every imported project.
Current IDE version:
File | New Project Settings | Settings for New Projects..., navigate to the compiler settings, annotation processing and enable this option before importing the project.
Previous versions:
File | Other Settings | Default Settings, navigate to the compiler settings, annotation processing and enable this option before importing the project.
Just switched to the Intellij Ultimate 14.1.4 IDE. Tried to build a simple Spring Boot helloworld endpoint but ran into several problems.
I first created a new Spring initializer project with no issues. I went through the various windows setting up the project with no issues. When the project was created it did not generate a Spring Boot main application class, which is no big deal; it's just an irritation for a newbie.
I selected src > file > new and tried to select a Java class but found that there was none in the drop down box. Most of the drop downs were JavaScript, CSS, and JSON files. I guess I do not have the correct default for Spring Boot. Anybody know how to set this up?
The crux of the issue is that you were not running that command in the context of a source or test folder. If you attempt to do any autogenerate commands in a non-source folder, you won't get the full set of things that can be generated.
The simple fix is to be sure that you're in the right folder - likely src/main/java.
If the folder isn't marked blue, then right-click on it, and select Mark Directory As > Sources Root.
This is what it appears when you don't have the folder marked as source:
...and this is what it looks like when you do: