0

The last few months I studied JavaEE. I've done several projects with complete functionality and working on localhost tomcat server.  

How to make a web application where I used Maven, Spring, MYSQL, Backbone ... put online. I know I need to charter a java hosting or a free, but do I need some extra settings and new files in my project

Do I need a folder structure as it is copied to the public file on hosting or make a WAR file that is copied to the hosting?

Xstian
  • 8,184
  • 10
  • 42
  • 72
zexco2
  • 149
  • 2
  • 18

2 Answers2

0

You only have to build the applicaton: "mvn install". This creates the war file. You only have to put this war file into your tomcat. The war contains all dependencies and everything you need. The tomcat automatically deploys your application.

To create a valid build, you have to use a JDK and not a JRE. Run As -> Maven Build ... -> Tab "JRE" -> select a JDK to build your project. If no JDK is listed, please download and install it: http://www.oracle.com/technetwork/java/javase/downloads/index.html

If you have no more error, the .war should appear in the "/target" folder.

If there is no .war file, pls check your pom.xml if it's valid. U need the packaging definition and maybe a war-plugin

<packaging>war</packaging>

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-war-plugin</artifactId>
    <version>2.0.1</version>
    <executions>
        <execution>
            <id>prepare-war</id>
            <phase>prepare-package</phase>
            <goals>
                <goal>exploded</goal>
            </goals>
        </execution>
    </executions>
</plugin>
NiceGuy
  • 133
  • 1
  • 14
  • I did maven installation. Where is created war file, in which folder ? There isn't in eclipse workspace and project folder ... PS. Thanks for your answer. – zexco2 Dec 05 '14 at 14:05
  • The build creates a "target" folder in your project. It .war file must be there. May be the build wasn't successful? Take a look at the console output, the name of the .war file must be displayed there. – NiceGuy Dec 05 '14 at 14:08
  • seems not to be successfully completed install ... I have a mistake --- No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK? ????? – zexco2 Dec 05 '14 at 14:12
  • Run As -> Maven Build ... -> Tab "JRE" -> select a JDK to build your project. You have selected a JRE but you need a JDK. – NiceGuy Dec 05 '14 at 14:17
  • I'm sorry to frequently asked questions, but when I go to the JRE where you said, I have no option to choose jdk, only more jre version.... – zexco2 Dec 05 '14 at 14:27
  • Than you have to download & install a jdk. After you have installed one, it's listed there. http://www.oracle.com/technetwork/java/javase/downloads/index.html – NiceGuy Dec 05 '14 at 14:28
  • It's working , I change jre with jdk and created war file ... now I try somehow put war file on hosting servis ... – zexco2 Dec 05 '14 at 15:39
0

When you deploy a .war file, Tomcat unpacks the the archive on the server, to a directory which will contain referenced libraries, as well as your js, sql, xml configuration, etc - so putting the .war on the external server should meet your needs.

I use mvn clean package which will assemble your project into the .war file. mvn install will actually install the package into your local maven repository, rather than just outputting your goal (a .war file) to the /target directory.

Check out this question, and also the intro to the maven lifecycle.

Community
  • 1
  • 1
lase
  • 2,508
  • 2
  • 24
  • 35
  • I try with mvn clean and BUILD SUCCESS - maven-clean-plugin:2.4.1:clean (default-clean) @ lab10-end --- [INFO] Deleting D:\lab10-end\target , but now in target folder I don't have .war file , only classes, m2e-wtp, test-classes folders ... – zexco2 Dec 05 '14 at 14:57
  • Did you try doing `mvn package` as well? – lase Dec 05 '14 at 15:02