Spring Boot无法通过多模块设置清除安装

时间:2018-06-13 01:44:03

标签: java maven spring-boot heroku compiler-errors

所以我有一个项目设置如下。这有两个模块web服务和工作服务。 在worker-service(BigOpertaion和RabbitMQListener)中有一些类,它们也在Web服务模块中定义。

例如,Web服务的主要类看起来像这样:

@SpringBootApplication
public class SpringBootHerokuExampleApplication {

    public final static String PDF_MERGE_QUEUE= "pdf-merge-queue";

    @Bean
    Queue queue(){
        return new Queue(PDF_MERGE_QUEUE, false);
    }

    @Bean
    TopicExchange exchange(){
        return new TopicExchange("pdf-nerge-exchange");
    }

    @Bean
    Binding binding(Queue queue, TopicExchange topicExchange){
        return BindingBuilder.bind(queue).to(topicExchange).with(PDF_MERGE_QUEUE);
    }

    @Bean
    SimpleMessageListenerContainer container(ConnectionFactory connectionFactory,
                                             MessageListenerAdapter listenerAdapter){
        SimpleMessageListenerContainer container = new SimpleMessageListenerContainer();
        container.setConnectionFactory(connectionFactory);
        container.setQueueNames(PDF_MERGE_QUEUE);
        container.setMessageListener(listenerAdapter);
        return container;
    }

    @Bean
    MessageListenerAdapter listenerAdapter(RabbitMQListener rabbitMQListener){
        return new MessageListenerAdapter(rabbitMQListener, "receiveMessage");
    }

    public static void main(String[] args) {
        SpringApplication.run(SpringBootHerokuExampleApplication.class, args);
    }
}

它注册了一个在worker-service模块中定义的监听器RabbitMQListener,这样一旦填充队列,工作线程就会监听。

Web服务的其余控制器定义为:

@RestController
public class MergePDFController {

    private static final org.slf4j.Logger LOGGER = LoggerFactory.getLogger(MergePDFController.class);

    @Autowired
    private RabbitTemplate rabbitTemplate;


    @RequestMapping(value = "/MergeNSplitService/merge", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON)
    public String mergeUsers(@RequestParam("fileIds") String fileIds,
                             @RequestParam("accessToken") String accessToken,
                             @RequestParam("instanceURL") String instanceURL,
                             @RequestParam("useSoap")boolean useSoap) {
        Gson gson = new GsonBuilder().disableHtmlEscaping().create();
        LOGGER.info("fileIds -> "+fileIds);
        LOGGER.info("accessToken -> "+accessToken);
        LOGGER.info("instanceURL -> "+instanceURL);
        LOGGER.info("useSoap -> "+useSoap);
        BigOpertaion bigOpertaion = new BigOpertaion();
        bigOpertaion.setFileIds(fileIds);
        bigOpertaion.setAccessToken(accessToken);
        bigOpertaion.setInstanceURL(instanceURL);
        bigOpertaion.setUseSoap(useSoap);
        rabbitTemplate.convertAndSend(SpringBootHerokuExampleApplication.PDF_MERGE_QUEUE, bigOpertaion);
        return gson.toJson("Merge PDF SUCCESS");

    }

    @RequestMapping(value = "/MergeNSplitService/split", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON)
    public String splitPDFs(@RequestParam("file1Id") String file1Id,
                            @RequestParam("parentId") String parentId,
                            @RequestParam("accessToken") String accessToken,
                            @RequestParam("instanceURL") String instanceURL,
                            @RequestParam("useSoap")boolean useSoap) {
        Gson gson = new GsonBuilder().disableHtmlEscaping().create();
        return gson.toJson("SPLIT PDF SUCCESS");

    }
}

但是在进行全新安装时,编译失败并显示以下消息:

[ERROR] COMPILATION ERROR : 
[INFO] -------------------------------------------------------------
[ERROR] /C:/Users/Nagendra/IdeaProjects/spring-boot-heroku-example/web-service/src/main/java/org/exampledriven/MergePDFController.java:[5,34] package org.exampledriven.rabbitMQ does not exist
[ERROR] /C:/Users/Nagendra/IdeaProjects/spring-boot-heroku-example/web-service/src/main/java/org/exampledriven/SpringBootHerokuExampleApplication.java:[3,34] package org.exampledriven.rabbitMQ does not exist
[ERROR] /C:/Users/Nagendra/IdeaProjects/spring-boot-heroku-example/web-service/src/main/java/org/exampledriven/SpringBootHerokuExampleApplication.java:[46,44] cannot find symbol
  symbol:   class RabbitMQListener
  location: class org.exampledriven.SpringBootHerokuExampleApplication
[ERROR] /C:/Users/Nagendra/IdeaProjects/spring-boot-heroku-example/web-service/src/main/java/org/exampledriven/MergePDFController.java:[35,9] cannot find symbol
  symbol:   class BigOpertaion
  location: class org.exampledriven.MergePDFController
[ERROR] /C:/Users/Nagendra/IdeaProjects/spring-boot-heroku-example/web-service/src/main/java/org/exampledriven/MergePDFController.java:[35,41] cannot find symbol
  symbol:   class BigOpertaion
  location: class org.exampledriven.MergePDFController

网络服务pom文件

<?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>org.exampledriven</groupId>
    <artifactId>web-service</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>

    <name>web-service</name>
    <description>Demo project for Spring Boot with Heroku</description>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.4.1.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <java.version>1.8</java.version>
        <full-artifact-name>target/${project.artifactId}-${project.version}.jar</full-artifact-name>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-amqp</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-jersey</artifactId>
        </dependency>
        <dependency>
            <groupId>com.google.code.gson</groupId>
            <artifactId>gson</artifactId>
            <version>2.8.0</version>
        </dependency>
        <dependency>
            <groupId>org.json</groupId>
            <artifactId>json</artifactId>
            <version>20180130</version>
        </dependency>
        <dependency>
            <groupId>org.exampledriven</groupId>
            <artifactId>worker-service</artifactId>
            <version>0.0.1-SNAPSHOT</version>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>

            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <version>1.4.1.RELEASE</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>build-info</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>pl.project13.maven</groupId>
                <artifactId>git-commit-id-plugin</artifactId>
                <configuration>
                    <dotGitDirectory>../.git</dotGitDirectory>
                </configuration>
            </plugin>

        </plugins>

    </build>

    <profiles>
        <profile>
            <id>heroku</id>
            <activation>
                <property>
                    <name>heroku</name>
                </property>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>com.heroku.sdk</groupId>
                        <artifactId>heroku-maven-plugin</artifactId>
                        <version>1.1.1</version>
                        <configuration>
                            <appName>exampledriven-springboot-dev</appName>
                            <includeTarget>false</includeTarget>
                            <includes>
                                <include>${basedir}/${full-artifact-name}</include>
                            </includes>
                            <jdkVersion>1.8</jdkVersion>
                            <processTypes>
                                <web>java $JAVA_OPTS -jar ${full-artifact-name} --spring.profiles.active=heroku</web>
                            </processTypes>
                        </configuration>
                        <executions>
                            <execution>
                                <phase>verify</phase>
                                <goals>
                                    <goal>deploy</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>


</project>

工作服务pom文件

<?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>org.exampledriven</groupId>
    <artifactId>worker-service</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>

    <name>worker-service</name>
    <description>Demo project for Spring Boot with Heroku</description>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.4.1.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <java.version>1.8</java.version>
        <full-artifact-name>target/${project.artifactId}-${project.version}.jar</full-artifact-name>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-amqp</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>

    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>

            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <version>1.4.1.RELEASE</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>build-info</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>pl.project13.maven</groupId>
                <artifactId>git-commit-id-plugin</artifactId>
                <configuration>
                    <dotGitDirectory>../.git</dotGitDirectory>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <id>heroku</id>
            <activation>
                <property>
                    <name>heroku</name>
                </property>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>com.heroku.sdk</groupId>
                        <artifactId>heroku-maven-plugin</artifactId>
                        <version>1.1.1</version>
                        <configuration>
                            <appName>exampledriven-springworker-dev</appName>
                            <includeTarget>false</includeTarget>
                            <includes>
                                <include>${basedir}/${full-artifact-name}</include>
                            </includes>
                            <jdkVersion>1.8</jdkVersion>
                            <processTypes>
                                <web>java $JAVA_OPTS -jar ${full-artifact-name} --spring.profiles.active=heroku</web>
                            </processTypes>
                        </configuration>
                        <executions>
                            <execution>
                                <phase>verify</phase>
                                <goals>
                                    <goal>deploy</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

</project>

Project Setup

0 个答案:

没有答案