The keyword is too verbose to help me find anything useful. Please pardon me if it's a stupid question.
I have two spring-boot projects, A and B, in the same directory. I run
mvn clean
mvn compile
mvn package
mvn spring-boot:run
in the directory of project A and want to run A. However, the pages of project B shows up (both of them use localhost:8080).
I tried the following but none worked:
Moved and renamed A to another directory and ran all the above commends again;
Clean brower cache or open in incog window;
Remove .m2 folder;
Reboot my laptop;
Run with IDE, mvn spring-boot:run, and java -jar target/ProjectA.jar;
Invalidate Cache/Restart in IntelliJ.
Also:
If I break Project A (make it fail to compile), mvn compile will fail;
If I break Project B, running A will still give me B;
If I change the contents of html files in B, it won't change the showing pages;
If I debug the project A, it will hit the main function in #SpringBootApplication;
Everything is running on Win10, no container or VM.
It seems I am running Project A, but it has neither MvcConfig nor html templates, where are those pages from? I did a thorough search for page contents, but the project directory of A didn't contain anything like that. So it must from somewhere else.
Github: https://github.com/PhoenixPan/finishthem-api-server
(doesn't have any visible html page)
Hope someone could explain why this is happening and how should I prevent it... Thanks.
Have you tried running your project A from your IDE as a simple java application? You can run a Spring Boot application from your IDE as a simple Java application. However, you first need to import your project. Import steps vary depending on your IDE and build system. Most IDEs can import Maven projects directly. For example, Eclipse users can select Import… → Existing Maven Projects from the File menu.
Related
We have the following project setup: Maven, Eclipse, Subversion. Eclipse Launch configurations are in a separate docs folder next to the pom.xml. The launch configurations run something like mvn clean install -Pdev or mvn tomee:run -pl something-ear
The good thing is that a shared run configuration is picked up by the IDE and shown in the External Tools run commands. This way, every developer that checks out this project immediately has access to run the build.
We would like to have something similar using IntelliJ IDEA, but I haven't found a good equivalent. What I have considered so far:
Share run scripts
My first idea was to replace the launch configurations with run scripts. I just could not figure out how to have those run scripts run inside IntelliJ IDEA just the way a Maven goal would be executed.
Share IDEA project configuration
The IDEA project configuration (specifically .idea/runConfigurations) inside the checked out directory is not a good solution. We have (speaking one IDEA project with different IDEA modules depending on the task at hand: as a developer you might need multiple IDEA modules (and sub-modules) in the same IDEA project
An IDEA project consisting of the following modules is not something unusal
projectA/trunk
projectB/tags/1.2
projectC/branches/some-change
My preferred solution would remove all IDE-specific configuration from the repository and have some kind of run definitions either in the project folder or a folder next to the pom.xml that a developer can run from the command line or from her IDE of choice.
The optimal solution would let me define something like this in the pom:
<runConfigs>
<default>clean install</default>
<container>tomee:run -pl something-ear</container>
</runConfigs>
This configuration would then be picked up by the IDE and provided as a run or launch configuration to the developer.
Any ideas or suggestions?
Thank you very much!
My current approach is a hybrid solution:
No configuration in the separate modules
One IDEA project configuration with run configurations managed in VCS
The .idea/runConfigurations directory is versioned separately from the project sources. It contains commands with a working directory set relative to the PROJECT_DIR:
<MavenRunnerParameters>
…
<option name="workingDirPath" value="$PROJECT_DIR$/path/to/submodule" />
</MavenRunnerParameters>
When setting up a new project, the developer also checks out this folder and has a set of pre-configured launch configurations for all projects. The downsides are
All launch configurations are managed centrally instead of with the module
The IDEA project directory has a fixed location relative to the modules. If you set up another project, you will have to change the run configurations
The setup does not clearly state how changes to the launch configurations are shared with other developers
I have created a maven vaadin project using the command line like this:
mvn archetype:generate -DarchetypeGroupId=com.vaadin -DarchetypeArtifactId=vaadin-archetype-application -DarchetypeVersion=7.1.9
Then I change into the folder of the application and I give at the command line the following :
mvn install
After waiting for the application to compile, I open it using IntelliJ Idea (by opening the pom.xml file), I add Tomcat Server and I press run.
Then the IntelliJ Ide recompiles the application again.
Is there any way I can avoid this second compilation?
Thank you.
You should have tomcat configured as a server, and configure your module(s) to deploy at server startup. On the run configuration you will see a list of things to do before launch. It will probably say Make -- you can remove this if you need to.
However, you probably should allow idea to do this for you and really stop doing it on the command line. Idea can handle more complex build patterns for you. You should trust it.
I have a regular maven module setup like:
src/main/java/...
src/main/test/com/example/...
So I have a junit test etc. inside my test folder, but for some reason after a while the folder setting reverts back to the default and then I can't run my tests using the right-click run test option.
I have to go back into the module settings and change it back to test.
This doesn't happen with my other maven modules (its a multi-module project).
What could the reason be?
I'm using version 12.1.4 ultimate.
I can confirm that this works fine for me on Intellij 12.0.4, 12.1.5 and 13.x (all Ultimate versions).
When I mark a folder (src/main/test in my experiment) it stays marked as a 'Test Source Root' after a restart.
(It's possibly a typo but) the directory structure you mentioned does not adhere to the maven Standard Directory Layout. If you move src/main/test/java/com/example to src/test/java/com/example (notice that there is a java in there, so test/java/com instead of test/com) you wouldn't have to explicitly mark the test folder.
I'm developing my first maven application and now i have this trouble, i performed the following commands
mvn compile
mvn package
mvn jboss-as-deploy
the deploy process ends without errors but in my JBOSS_HOME\standalone\deployments i don't find the .war
why?
Try to set targetDir option (maybe the default is overriden in your environoment?). See http://docs.jboss.org/jbossas/7/plugins/maven/latest/deploy-mojo.html.
The $JBOSS_HOME/standalone/deployments directory is not where deployments are stored. If you look in that directory there is a README file that explains it's what the directory is used for.
The jboss-as-maven-plugin uses the deployment API's to deploy the content to the server. This generally ends up in $JBOSS_HOME/standalone/data/content for a standalone server. Though you really shouldn't be doing anything with files in that directory.
Using NetBeans 7.1.2.
When editing pages with NetBeans as per the procedure explained below, the IDE offers only autocompletion for <jsp:...> tags:
This is how I have created the NetBeans project and the jsp (though it isn't archetype specific, nor the issue has anything to do with opencms): I have created a maven project with the OpenCms-Module archetype
mvn archetype:generate -DarchetypeCatalog=http://bp-cms-commons.sourceforge.net/m2repo
The archetype creates a maven project with jar packaging.
After that, I have added a jsp under src/main/opencms/modules/blahblah/templates.
And then I have added the taglibs.standard dependency to the project, to try to provide NetBeans with the corresponding tlds.
After several hours trying to get this working, I found this reported and closed bug that hinted me into the right direction:
Added src/main/webapp directory Edit 1: There is autocompletion only for jstl tags if the files are inside src/main/webapp. Workaround in linux (not sure if windows links will work): Create a symlink:
ln -s opencms/ src/main/webapp from the project root folder
Change maven project packaging to war (Project properties -> General -> Packaging)
(Notice that neither the #taglib directive nor the taglibs.standard dependency are necessary.)
If the Web Pages entry does not appear under your project (in the projects view), you may need to restart NetBeans. Now you'll have full autocompletion (only) under src/main/webapp! :-)
Edit 2
Unfortunately, if under version control, NetBeans sees the symlink as a new directory, and all files under it, as new files :-( This is very inconvenient, because to access the IDE integrated version control functionality, you still need to open the original resource.