Results 1 to 3 of 3

Thread: Java files deployed to TC server and build in WAR?

  1. #1

    Default Java files deployed to TC server and build in WAR?

    I am starting to use the java config rather than the XML. I have used the Greenhouse project as a reference. Now in my project (as well as in the Greenhouse app) all the java files are ending up in the WAR. I don't understand how they are getting there but I only want class files in the WAR.

    One other issue I am seeing is just like you would sometimes have a test-context.xml I have a testConfig.java annotated with @Configuration needed for my Junit test cases. Problem this is also getting picked up byTCServer and being deployed. This caused some really difficult issues for me to debug today until I finally figured out that TCServer was creating and using beans defined in a configuration file in my /test directory.

    In short I have 2 questions

    1. How can I ensure that I do not package source code in my war or have STS deploy it to TC server?
    2. How can I ensure that absolutely nothing from the test directory in my project ends up in the WAR or deployed? I am wondering if it has something to do with the way that the AnnotationConfigWebApplicationContext scans packages. If I have src/main/java/com/example/config/config.java and src/main/test/com/example/configTest.java I would hope that it would not pick up the one under test.

    Has anyone had this issue or know of a solution?

    Thanks,

  2. #2

    Default

    OK so I got the test files out apparently my parent pom setting were having no effect so I added

    Code:
    		<testResources>
    			<testResource>
    				<directory>src/test/java</directory>
    			</testResource>
    			<testResource>
    				<directory>src/test/resources</directory>
    			</testResource>	
    		</testResources>
    In my project POM. However that does not explain why the source (.java) files are being included in the WAR. Has anyone built the Greenhouse project and noticed this? How can I change this behavior?

    Thanks,

  3. #3

    Default Solved

    Ok the problem is they have .xml config files in src/main/java instead of in the resource directory like you normally would. You should usually only have resources directories in the <resource> tags in your POM. Here is what it should be (refer to the greenhouse project POM)
    Code:
    	<resources>
    			<resource>
    				<directory>src/main/java</directory>
    		        <filtering>true</filtering>
    		        <includes>
    		          <include>**/*.xml</include>
    		        </includes>
    			</resource>	
    			<resource>
    				<directory>src/main/resources</directory>
    			</resource>		
    		</resources>
    		<testResources>
    			<testResource>
    				<directory>src/test/resources</directory>
    			</testResource>	
    		</testResources>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •